@wordpress/core-data 7.32.0 → 7.32.1-next.ff1cebbba.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 (383) hide show
  1. package/build/actions.js +375 -632
  2. package/build/actions.js.map +7 -1
  3. package/build/batch/create-batch.js +49 -62
  4. package/build/batch/create-batch.js.map +7 -1
  5. package/build/batch/default-processor.js +43 -39
  6. package/build/batch/default-processor.js.map +7 -1
  7. package/build/batch/index.js +38 -17
  8. package/build/batch/index.js.map +7 -1
  9. package/build/dynamic-entities.js +30 -32
  10. package/build/dynamic-entities.js.map +7 -1
  11. package/build/entities.js +298 -410
  12. package/build/entities.js.map +7 -1
  13. package/build/entity-context.js +29 -12
  14. package/build/entity-context.js.map +7 -1
  15. package/build/entity-provider.js +38 -46
  16. package/build/entity-provider.js.map +7 -1
  17. package/build/entity-types/attachment.js +16 -5
  18. package/build/entity-types/attachment.js.map +7 -1
  19. package/build/entity-types/base-entity-records.js +16 -42
  20. package/build/entity-types/base-entity-records.js.map +7 -1
  21. package/build/entity-types/base.js +16 -5
  22. package/build/entity-types/base.js.map +7 -1
  23. package/build/entity-types/comment.js +16 -5
  24. package/build/entity-types/comment.js.map +7 -1
  25. package/build/entity-types/global-styles-revision.js +16 -5
  26. package/build/entity-types/global-styles-revision.js.map +7 -1
  27. package/build/entity-types/helpers.js +16 -5
  28. package/build/entity-types/helpers.js.map +7 -1
  29. package/build/entity-types/index.js +16 -5
  30. package/build/entity-types/index.js.map +7 -1
  31. package/build/entity-types/menu-location.js +16 -5
  32. package/build/entity-types/menu-location.js.map +7 -1
  33. package/build/entity-types/nav-menu-item.js +16 -5
  34. package/build/entity-types/nav-menu-item.js.map +7 -1
  35. package/build/entity-types/nav-menu.js +16 -5
  36. package/build/entity-types/nav-menu.js.map +7 -1
  37. package/build/entity-types/page.js +16 -5
  38. package/build/entity-types/page.js.map +7 -1
  39. package/build/entity-types/plugin.js +16 -5
  40. package/build/entity-types/plugin.js.map +7 -1
  41. package/build/entity-types/post-revision.js +16 -5
  42. package/build/entity-types/post-revision.js.map +7 -1
  43. package/build/entity-types/post-status.js +16 -5
  44. package/build/entity-types/post-status.js.map +7 -1
  45. package/build/entity-types/post.js +16 -5
  46. package/build/entity-types/post.js.map +7 -1
  47. package/build/entity-types/settings.js +16 -5
  48. package/build/entity-types/settings.js.map +7 -1
  49. package/build/entity-types/sidebar.js +16 -5
  50. package/build/entity-types/sidebar.js.map +7 -1
  51. package/build/entity-types/taxonomy.js +16 -5
  52. package/build/entity-types/taxonomy.js.map +7 -1
  53. package/build/entity-types/term.js +16 -5
  54. package/build/entity-types/term.js.map +7 -1
  55. package/build/entity-types/theme.js +16 -5
  56. package/build/entity-types/theme.js.map +7 -1
  57. package/build/entity-types/type.js +16 -5
  58. package/build/entity-types/type.js.map +7 -1
  59. package/build/entity-types/user.js +16 -5
  60. package/build/entity-types/user.js.map +7 -1
  61. package/build/entity-types/widget-type.js +16 -5
  62. package/build/entity-types/widget-type.js.map +7 -1
  63. package/build/entity-types/widget.js +16 -5
  64. package/build/entity-types/widget.js.map +7 -1
  65. package/build/entity-types/wp-template-part.js +16 -5
  66. package/build/entity-types/wp-template-part.js.map +7 -1
  67. package/build/entity-types/wp-template.js +16 -5
  68. package/build/entity-types/wp-template.js.map +7 -1
  69. package/build/fetch/__experimental-fetch-link-suggestions.js +141 -154
  70. package/build/fetch/__experimental-fetch-link-suggestions.js.map +7 -1
  71. package/build/fetch/__experimental-fetch-url-data.js +47 -59
  72. package/build/fetch/__experimental-fetch-url-data.js.map +7 -1
  73. package/build/fetch/index.js +53 -32
  74. package/build/fetch/index.js.map +7 -1
  75. package/build/footnotes/get-footnotes-order.js +38 -25
  76. package/build/footnotes/get-footnotes-order.js.map +7 -1
  77. package/build/footnotes/get-rich-text-values-cached.js +26 -27
  78. package/build/footnotes/get-rich-text-values-cached.js.map +7 -1
  79. package/build/footnotes/index.js +68 -55
  80. package/build/footnotes/index.js.map +7 -1
  81. package/build/hooks/constants.js +33 -12
  82. package/build/hooks/constants.js.map +7 -1
  83. package/build/hooks/index.js +59 -68
  84. package/build/hooks/index.js.map +7 -1
  85. package/build/hooks/memoize.js +34 -12
  86. package/build/hooks/memoize.js.map +7 -1
  87. package/build/hooks/use-entity-block-editor.js +111 -119
  88. package/build/hooks/use-entity-block-editor.js.map +7 -1
  89. package/build/hooks/use-entity-id.js +25 -23
  90. package/build/hooks/use-entity-id.js.map +7 -1
  91. package/build/hooks/use-entity-prop.js +59 -60
  92. package/build/hooks/use-entity-prop.js.map +7 -1
  93. package/build/hooks/use-entity-record.js +95 -155
  94. package/build/hooks/use-entity-record.js.map +7 -1
  95. package/build/hooks/use-entity-records.js +131 -139
  96. package/build/hooks/use-entity-records.js.map +7 -1
  97. package/build/hooks/use-query-select.js +65 -84
  98. package/build/hooks/use-query-select.js.map +7 -1
  99. package/build/hooks/use-resource-permissions.js +92 -145
  100. package/build/hooks/use-resource-permissions.js.map +7 -1
  101. package/build/index.js +96 -153
  102. package/build/index.js.map +7 -1
  103. package/build/lock-unlock.js +31 -14
  104. package/build/lock-unlock.js.map +7 -1
  105. package/build/locks/actions.js +36 -19
  106. package/build/locks/actions.js.map +7 -1
  107. package/build/locks/engine.js +48 -47
  108. package/build/locks/engine.js.map +7 -1
  109. package/build/locks/reducer.js +54 -63
  110. package/build/locks/reducer.js.map +7 -1
  111. package/build/locks/selectors.js +35 -30
  112. package/build/locks/selectors.js.map +7 -1
  113. package/build/locks/utils.js +37 -16
  114. package/build/locks/utils.js.map +7 -1
  115. package/build/name.js +27 -12
  116. package/build/name.js.map +7 -1
  117. package/build/private-actions.js +67 -75
  118. package/build/private-actions.js.map +7 -1
  119. package/build/private-apis.js +33 -16
  120. package/build/private-apis.js.map +7 -1
  121. package/build/private-selectors.js +204 -184
  122. package/build/private-selectors.js.map +7 -1
  123. package/build/queried-data/actions.js +32 -41
  124. package/build/queried-data/actions.js.map +7 -1
  125. package/build/queried-data/get-query-parts.js +41 -79
  126. package/build/queried-data/get-query-parts.js.map +7 -1
  127. package/build/queried-data/index.js +39 -36
  128. package/build/queried-data/index.js.map +7 -1
  129. package/build/queried-data/reducer.js +162 -193
  130. package/build/queried-data/reducer.js.map +7 -1
  131. package/build/queried-data/selectors.js +57 -85
  132. package/build/queried-data/selectors.js.map +7 -1
  133. package/build/reducer.js +279 -404
  134. package/build/reducer.js.map +7 -1
  135. package/build/resolvers.js +553 -600
  136. package/build/resolvers.js.map +7 -1
  137. package/build/selectors.js +456 -981
  138. package/build/selectors.js.map +7 -1
  139. package/build/sync.js +34 -22
  140. package/build/sync.js.map +7 -1
  141. package/build/types.js +16 -5
  142. package/build/types.js.map +7 -1
  143. package/build/utils/conservative-map-item.js +34 -27
  144. package/build/utils/conservative-map-item.js.map +7 -1
  145. package/build/utils/crdt-blocks.js +289 -0
  146. package/build/utils/crdt-blocks.js.map +7 -0
  147. package/build/utils/crdt.js +202 -0
  148. package/build/utils/crdt.js.map +7 -0
  149. package/build/utils/forward-resolver.js +24 -16
  150. package/build/utils/forward-resolver.js.map +7 -1
  151. package/build/utils/get-nested-value.js +26 -21
  152. package/build/utils/get-nested-value.js.map +7 -1
  153. package/build/utils/get-normalized-comma-separable.js +25 -17
  154. package/build/utils/get-normalized-comma-separable.js.map +7 -1
  155. package/build/utils/if-matching-action.js +25 -19
  156. package/build/utils/if-matching-action.js.map +7 -1
  157. package/build/utils/index.js +77 -108
  158. package/build/utils/index.js.map +7 -1
  159. package/build/utils/is-numeric-id.js +22 -12
  160. package/build/utils/is-numeric-id.js.map +7 -1
  161. package/build/utils/is-raw-attribute.js +22 -13
  162. package/build/utils/is-raw-attribute.js.map +7 -1
  163. package/build/utils/log-entity-deprecation.js +37 -38
  164. package/build/utils/log-entity-deprecation.js.map +7 -1
  165. package/build/utils/on-sub-key.js +30 -24
  166. package/build/utils/on-sub-key.js.map +7 -1
  167. package/build/utils/receive-intermediate-results.js +29 -6
  168. package/build/utils/receive-intermediate-results.js.map +7 -1
  169. package/build/utils/replace-action.js +24 -17
  170. package/build/utils/replace-action.js.map +7 -1
  171. package/build/utils/set-nested-value.js +25 -30
  172. package/build/utils/set-nested-value.js.map +7 -1
  173. package/build/utils/user-permissions.js +41 -13
  174. package/build/utils/user-permissions.js.map +7 -1
  175. package/build/utils/with-weak-map-cache.js +26 -22
  176. package/build/utils/with-weak-map-cache.js.map +7 -1
  177. package/build-module/actions.js +322 -601
  178. package/build-module/actions.js.map +7 -1
  179. package/build-module/batch/create-batch.js +21 -57
  180. package/build-module/batch/create-batch.js.map +7 -1
  181. package/build-module/batch/default-processor.js +14 -33
  182. package/build-module/batch/default-processor.js.map +7 -1
  183. package/build-module/batch/index.js +7 -3
  184. package/build-module/batch/index.js.map +7 -1
  185. package/build-module/dynamic-entities.js +7 -28
  186. package/build-module/dynamic-entities.js.map +7 -1
  187. package/build-module/entities.js +263 -399
  188. package/build-module/entities.js.map +7 -1
  189. package/build-module/entity-context.js +7 -7
  190. package/build-module/entity-context.js.map +7 -1
  191. package/build-module/entity-provider.js +19 -42
  192. package/build-module/entity-provider.js.map +7 -1
  193. package/build-module/entity-types/attachment.js +1 -2
  194. package/build-module/entity-types/attachment.js.map +7 -1
  195. package/build-module/entity-types/base-entity-records.js +1 -37
  196. package/build-module/entity-types/base-entity-records.js.map +7 -1
  197. package/build-module/entity-types/base.js +1 -2
  198. package/build-module/entity-types/base.js.map +7 -1
  199. package/build-module/entity-types/comment.js +1 -2
  200. package/build-module/entity-types/comment.js.map +7 -1
  201. package/build-module/entity-types/global-styles-revision.js +1 -2
  202. package/build-module/entity-types/global-styles-revision.js.map +7 -1
  203. package/build-module/entity-types/helpers.js +1 -2
  204. package/build-module/entity-types/helpers.js.map +7 -1
  205. package/build-module/entity-types/index.js +1 -2
  206. package/build-module/entity-types/index.js.map +7 -1
  207. package/build-module/entity-types/menu-location.js +1 -2
  208. package/build-module/entity-types/menu-location.js.map +7 -1
  209. package/build-module/entity-types/nav-menu-item.js +1 -2
  210. package/build-module/entity-types/nav-menu-item.js.map +7 -1
  211. package/build-module/entity-types/nav-menu.js +1 -2
  212. package/build-module/entity-types/nav-menu.js.map +7 -1
  213. package/build-module/entity-types/page.js +1 -2
  214. package/build-module/entity-types/page.js.map +7 -1
  215. package/build-module/entity-types/plugin.js +1 -2
  216. package/build-module/entity-types/plugin.js.map +7 -1
  217. package/build-module/entity-types/post-revision.js +1 -2
  218. package/build-module/entity-types/post-revision.js.map +7 -1
  219. package/build-module/entity-types/post-status.js +1 -2
  220. package/build-module/entity-types/post-status.js.map +7 -1
  221. package/build-module/entity-types/post.js +1 -2
  222. package/build-module/entity-types/post.js.map +7 -1
  223. package/build-module/entity-types/settings.js +1 -2
  224. package/build-module/entity-types/settings.js.map +7 -1
  225. package/build-module/entity-types/sidebar.js +1 -2
  226. package/build-module/entity-types/sidebar.js.map +7 -1
  227. package/build-module/entity-types/taxonomy.js +1 -2
  228. package/build-module/entity-types/taxonomy.js.map +7 -1
  229. package/build-module/entity-types/term.js +1 -2
  230. package/build-module/entity-types/term.js.map +7 -1
  231. package/build-module/entity-types/theme.js +1 -2
  232. package/build-module/entity-types/theme.js.map +7 -1
  233. package/build-module/entity-types/type.js +1 -2
  234. package/build-module/entity-types/type.js.map +7 -1
  235. package/build-module/entity-types/user.js +1 -2
  236. package/build-module/entity-types/user.js.map +7 -1
  237. package/build-module/entity-types/widget-type.js +1 -2
  238. package/build-module/entity-types/widget-type.js.map +7 -1
  239. package/build-module/entity-types/widget.js +1 -2
  240. package/build-module/entity-types/widget.js.map +7 -1
  241. package/build-module/entity-types/wp-template-part.js +1 -2
  242. package/build-module/entity-types/wp-template-part.js.map +7 -1
  243. package/build-module/entity-types/wp-template.js +1 -2
  244. package/build-module/entity-types/wp-template.js.map +7 -1
  245. package/build-module/fetch/__experimental-fetch-link-suggestions.js +111 -149
  246. package/build-module/fetch/__experimental-fetch-link-suggestions.js.map +7 -1
  247. package/build-module/fetch/__experimental-fetch-url-data.js +20 -49
  248. package/build-module/fetch/__experimental-fetch-url-data.js.map +7 -1
  249. package/build-module/fetch/index.js +20 -15
  250. package/build-module/fetch/index.js.map +7 -1
  251. package/build-module/footnotes/get-footnotes-order.js +10 -19
  252. package/build-module/footnotes/get-footnotes-order.js.map +7 -1
  253. package/build-module/footnotes/get-rich-text-values-cached.js +8 -23
  254. package/build-module/footnotes/get-rich-text-values-cached.js.map +7 -1
  255. package/build-module/footnotes/index.js +34 -47
  256. package/build-module/footnotes/index.js.map +7 -1
  257. package/build-module/hooks/constants.js +11 -8
  258. package/build-module/hooks/constants.js.map +7 -1
  259. package/build-module/hooks/index.js +27 -15
  260. package/build-module/hooks/index.js.map +7 -1
  261. package/build-module/hooks/memoize.js +6 -8
  262. package/build-module/hooks/memoize.js.map +7 -1
  263. package/build-module/hooks/use-entity-block-editor.js +80 -110
  264. package/build-module/hooks/use-entity-block-editor.js.map +7 -1
  265. package/build-module/hooks/use-entity-id.js +7 -19
  266. package/build-module/hooks/use-entity-id.js.map +7 -1
  267. package/build-module/hooks/use-entity-prop.js +31 -55
  268. package/build-module/hooks/use-entity-prop.js.map +7 -1
  269. package/build-module/hooks/use-entity-record.js +63 -148
  270. package/build-module/hooks/use-entity-record.js.map +7 -1
  271. package/build-module/hooks/use-entity-records.js +98 -131
  272. package/build-module/hooks/use-entity-records.js.map +7 -1
  273. package/build-module/hooks/use-query-select.js +27 -71
  274. package/build-module/hooks/use-query-select.js.map +7 -1
  275. package/build-module/hooks/use-resource-permissions.js +57 -136
  276. package/build-module/hooks/use-resource-permissions.js.map +7 -1
  277. package/build-module/index.js +49 -71
  278. package/build-module/index.js.map +7 -1
  279. package/build-module/lock-unlock.js +8 -7
  280. package/build-module/lock-unlock.js.map +7 -1
  281. package/build-module/locks/actions.js +8 -13
  282. package/build-module/locks/actions.js.map +7 -1
  283. package/build-module/locks/engine.js +17 -38
  284. package/build-module/locks/engine.js.map +7 -1
  285. package/build-module/locks/reducer.js +37 -59
  286. package/build-module/locks/reducer.js.map +7 -1
  287. package/build-module/locks/selectors.js +16 -23
  288. package/build-module/locks/selectors.js.map +7 -1
  289. package/build-module/locks/utils.js +15 -12
  290. package/build-module/locks/utils.js.map +7 -1
  291. package/build-module/name.js +5 -8
  292. package/build-module/name.js.map +7 -1
  293. package/build-module/private-actions.js +35 -69
  294. package/build-module/private-actions.js.map +7 -1
  295. package/build-module/private-apis.js +8 -8
  296. package/build-module/private-apis.js.map +7 -1
  297. package/build-module/private-selectors.js +167 -174
  298. package/build-module/private-selectors.js.map +7 -1
  299. package/build-module/queried-data/actions.js +11 -38
  300. package/build-module/queried-data/actions.js.map +7 -1
  301. package/build-module/queried-data/get-query-parts.js +20 -75
  302. package/build-module/queried-data/get-query-parts.js.map +7 -1
  303. package/build-module/queried-data/index.js +7 -4
  304. package/build-module/queried-data/index.js.map +7 -1
  305. package/build-module/queried-data/reducer.js +134 -185
  306. package/build-module/queried-data/reducer.js.map +7 -1
  307. package/build-module/queried-data/selectors.js +23 -78
  308. package/build-module/queried-data/selectors.js.map +7 -1
  309. package/build-module/reducer.js +243 -393
  310. package/build-module/reducer.js.map +7 -1
  311. package/build-module/resolvers.js +478 -549
  312. package/build-module/resolvers.js.map +7 -1
  313. package/build-module/selectors.js +410 -953
  314. package/build-module/selectors.js.map +7 -1
  315. package/build-module/sync.js +14 -17
  316. package/build-module/sync.js.map +7 -1
  317. package/build-module/types.js +1 -2
  318. package/build-module/types.js.map +7 -1
  319. package/build-module/utils/conservative-map-item.js +6 -22
  320. package/build-module/utils/conservative-map-item.js.map +7 -1
  321. package/build-module/utils/crdt-blocks.js +255 -0
  322. package/build-module/utils/crdt-blocks.js.map +7 -0
  323. package/build-module/utils/crdt.js +167 -0
  324. package/build-module/utils/crdt.js.map +7 -0
  325. package/build-module/utils/forward-resolver.js +6 -12
  326. package/build-module/utils/forward-resolver.js.map +7 -1
  327. package/build-module/utils/get-nested-value.js +9 -18
  328. package/build-module/utils/get-nested-value.js.map +7 -1
  329. package/build-module/utils/get-normalized-comma-separable.js +7 -13
  330. package/build-module/utils/get-normalized-comma-separable.js.map +7 -1
  331. package/build-module/utils/if-matching-action.js +7 -15
  332. package/build-module/utils/if-matching-action.js.map +7 -1
  333. package/build-module/utils/index.js +35 -14
  334. package/build-module/utils/index.js.map +7 -1
  335. package/build-module/utils/is-numeric-id.js +5 -9
  336. package/build-module/utils/is-numeric-id.js.map +7 -1
  337. package/build-module/utils/is-raw-attribute.js +5 -10
  338. package/build-module/utils/is-raw-attribute.js.map +7 -1
  339. package/build-module/utils/log-entity-deprecation.js +8 -31
  340. package/build-module/utils/log-entity-deprecation.js.map +7 -1
  341. package/build-module/utils/on-sub-key.js +8 -19
  342. package/build-module/utils/on-sub-key.js.map +7 -1
  343. package/build-module/utils/receive-intermediate-results.js +7 -2
  344. package/build-module/utils/receive-intermediate-results.js.map +7 -1
  345. package/build-module/utils/replace-action.js +6 -13
  346. package/build-module/utils/replace-action.js.map +7 -1
  347. package/build-module/utils/set-nested-value.js +8 -27
  348. package/build-module/utils/set-nested-value.js.map +7 -1
  349. package/build-module/utils/user-permissions.js +19 -9
  350. package/build-module/utils/user-permissions.js.map +7 -1
  351. package/build-module/utils/with-weak-map-cache.js +8 -18
  352. package/build-module/utils/with-weak-map-cache.js.map +7 -1
  353. package/build-types/actions.d.ts.map +1 -1
  354. package/build-types/entities.d.ts +0 -56
  355. package/build-types/entities.d.ts.map +1 -1
  356. package/build-types/index.d.ts.map +1 -1
  357. package/build-types/private-selectors.d.ts.map +1 -1
  358. package/build-types/resolvers.d.ts +3 -0
  359. package/build-types/resolvers.d.ts.map +1 -1
  360. package/build-types/selectors.d.ts.map +1 -1
  361. package/build-types/sync.d.ts +6 -1
  362. package/build-types/sync.d.ts.map +1 -1
  363. package/build-types/types.d.ts +9 -0
  364. package/build-types/types.d.ts.map +1 -1
  365. package/build-types/utils/crdt-blocks.d.ts +30 -0
  366. package/build-types/utils/crdt-blocks.d.ts.map +1 -0
  367. package/build-types/utils/crdt.d.ts +49 -0
  368. package/build-types/utils/crdt.d.ts.map +1 -0
  369. package/package.json +26 -19
  370. package/src/actions.js +56 -74
  371. package/src/entities.js +59 -113
  372. package/src/private-selectors.ts +32 -7
  373. package/src/resolvers.js +173 -120
  374. package/src/selectors.ts +0 -13
  375. package/src/sync.ts +12 -0
  376. package/src/test/resolvers.js +183 -0
  377. package/src/types.ts +12 -0
  378. package/src/utils/crdt-blocks.ts +503 -0
  379. package/src/utils/crdt.ts +310 -0
  380. package/src/utils/test/crdt-blocks.ts +375 -0
  381. package/src/utils/test/crdt.ts +254 -0
  382. package/tsconfig.tsbuildinfo +1 -1
  383. package/src/sync.js +0 -27
@@ -1,313 +1,315 @@
1
- /**
2
- * External dependencies
3
- */
4
- import { camelCase } from 'change-case';
5
-
6
- /**
7
- * WordPress dependencies
8
- */
9
- import { addQueryArgs } from '@wordpress/url';
10
- import { decodeEntities } from '@wordpress/html-entities';
11
- import apiFetch from '@wordpress/api-fetch';
12
-
13
- /**
14
- * Internal dependencies
15
- */
16
- import { STORE_NAME } from './name';
17
- import { additionalEntityConfigLoaders, DEFAULT_ENTITY_KEY } from './entities';
18
- import { forwardResolver, getNormalizedCommaSeparable, getUserPermissionCacheKey, getUserPermissionsFromAllowHeader, ALLOWED_RESOURCE_ACTIONS, RECEIVE_INTERMEDIATE_RESULTS } from './utils';
19
- import { getSyncProvider } from './sync';
20
- import { fetchBlockPatterns } from './fetch';
21
-
22
- /**
23
- * Requests authors from the REST API.
24
- *
25
- * @param {Object|undefined} query Optional object of query parameters to
26
- * include with request.
27
- */
28
- export const getAuthors = query => async ({
29
- dispatch
30
- }) => {
31
- const path = addQueryArgs('/wp/v2/users/?who=authors&per_page=100', query);
32
- const users = await apiFetch({
33
- path
34
- });
1
+ import { camelCase } from "change-case";
2
+ import { addQueryArgs } from "@wordpress/url";
3
+ import { decodeEntities } from "@wordpress/html-entities";
4
+ import apiFetch from "@wordpress/api-fetch";
5
+ import { STORE_NAME } from "./name";
6
+ import { additionalEntityConfigLoaders, DEFAULT_ENTITY_KEY } from "./entities";
7
+ import { syncManager } from "./sync";
8
+ import {
9
+ forwardResolver,
10
+ getNormalizedCommaSeparable,
11
+ getUserPermissionCacheKey,
12
+ getUserPermissionsFromAllowHeader,
13
+ ALLOWED_RESOURCE_ACTIONS,
14
+ RECEIVE_INTERMEDIATE_RESULTS
15
+ } from "./utils";
16
+ import { fetchBlockPatterns } from "./fetch";
17
+ const getAuthors = (query) => async ({ dispatch }) => {
18
+ const path = addQueryArgs(
19
+ "/wp/v2/users/?who=authors&per_page=100",
20
+ query
21
+ );
22
+ const users = await apiFetch({ path });
35
23
  dispatch.receiveUserQuery(path, users);
36
24
  };
37
-
38
- /**
39
- * Requests the current user from the REST API.
40
- */
41
- export const getCurrentUser = () => async ({
42
- dispatch
43
- }) => {
44
- const currentUser = await apiFetch({
45
- path: '/wp/v2/users/me'
46
- });
25
+ const getCurrentUser = () => async ({ dispatch }) => {
26
+ const currentUser = await apiFetch({ path: "/wp/v2/users/me" });
47
27
  dispatch.receiveCurrentUser(currentUser);
48
28
  };
49
-
50
- /**
51
- * Requests an entity's record from the REST API.
52
- *
53
- * @param {string} kind Entity kind.
54
- * @param {string} name Entity name.
55
- * @param {number|string} key Record's key
56
- * @param {Object|undefined} query Optional object of query parameters to
57
- * include with request. If requesting specific
58
- * fields, fields must always include the ID.
59
- */
60
- export const getEntityRecord = (kind, name, key = '', query) => async ({
61
- select,
62
- dispatch,
63
- registry,
64
- resolveSelect
65
- }) => {
66
- // For back-compat, we allow querying for static templates through
67
- // wp_template.
68
- if (kind === 'postType' && name === 'wp_template' && typeof key === 'string' &&
69
- // __experimentalGetDirtyEntityRecords always calls getEntityRecord
70
- // with a string key, so we need that it's not a numeric ID.
71
- !/^\d+$/.test(key)) {
72
- name = 'wp_registered_template';
73
- }
29
+ const getEntityRecord = (kind, name, key = "", query) => async ({ select, dispatch, registry, resolveSelect }) => {
74
30
  const configs = await resolveSelect.getEntitiesConfig(kind);
75
- const entityConfig = configs.find(config => config.name === name && config.kind === kind);
31
+ const entityConfig = configs.find(
32
+ (config) => config.name === name && config.kind === kind
33
+ );
76
34
  if (!entityConfig) {
77
35
  return;
78
36
  }
79
- const lock = await dispatch.__unstableAcquireStoreLock(STORE_NAME, ['entities', 'records', kind, name, key], {
80
- exclusive: false
81
- });
37
+ const lock = await dispatch.__unstableAcquireStoreLock(
38
+ STORE_NAME,
39
+ ["entities", "records", kind, name, key],
40
+ { exclusive: false }
41
+ );
82
42
  try {
83
- // Entity supports configs,
84
- // use the sync algorithm instead of the old fetch behavior.
43
+ if (query !== void 0 && query._fields) {
44
+ query = {
45
+ ...query,
46
+ _fields: [
47
+ .../* @__PURE__ */ new Set([
48
+ ...getNormalizedCommaSeparable(query._fields) || [],
49
+ entityConfig.key || DEFAULT_ENTITY_KEY
50
+ ])
51
+ ].join()
52
+ };
53
+ }
54
+ if (query !== void 0 && query._fields) {
55
+ const hasRecord = select.hasEntityRecord(
56
+ kind,
57
+ name,
58
+ key,
59
+ query
60
+ );
61
+ if (hasRecord) {
62
+ return;
63
+ }
64
+ }
65
+ let { baseURL } = entityConfig;
66
+ if (kind === "postType" && name === "wp_template" && key && typeof key === "string" && !/^\d+$/.test(key)) {
67
+ baseURL = baseURL.slice(0, baseURL.lastIndexOf("/")) + "/templates";
68
+ }
69
+ const path = addQueryArgs(baseURL + (key ? "/" + key : ""), {
70
+ ...entityConfig.baseURLParams,
71
+ ...query
72
+ });
73
+ const response = await apiFetch({ path, parse: false });
74
+ const record = await response.json();
75
+ const permissions = getUserPermissionsFromAllowHeader(
76
+ response.headers?.get("allow")
77
+ );
78
+ const canUserResolutionsArgs = [];
79
+ const receiveUserPermissionArgs = {};
80
+ for (const action of ALLOWED_RESOURCE_ACTIONS) {
81
+ receiveUserPermissionArgs[getUserPermissionCacheKey(action, {
82
+ kind,
83
+ name,
84
+ id: key
85
+ })] = permissions[action];
86
+ canUserResolutionsArgs.push([
87
+ action,
88
+ { kind, name, id: key }
89
+ ]);
90
+ }
85
91
  if (window.__experimentalEnableSync && entityConfig.syncConfig && !query) {
86
92
  if (globalThis.IS_GUTENBERG_PLUGIN) {
87
- const objectId = entityConfig.getSyncObjectId(key);
88
-
89
- // Loads the persisted document.
90
- await getSyncProvider().bootstrap(entityConfig.syncObjectType, objectId, record => {
91
- dispatch.receiveEntityRecords(kind, name, record, query);
93
+ const objectType = `${kind}/${name}`;
94
+ const objectId = key;
95
+ const recordWithTransients = { ...record };
96
+ Object.entries(entityConfig.transientEdits ?? {}).filter(
97
+ ([propName, transientConfig]) => void 0 === recordWithTransients[propName] && transientConfig && "object" === typeof transientConfig && "read" in transientConfig && "function" === typeof transientConfig.read
98
+ ).forEach(([propName, transientConfig]) => {
99
+ recordWithTransients[propName] = transientConfig.read(recordWithTransients);
92
100
  });
93
-
94
- // Bootstraps the edited document as well (and load from peers).
95
- await getSyncProvider().bootstrap(entityConfig.syncObjectType + '--edit', objectId, record => {
96
- dispatch({
97
- type: 'EDIT_ENTITY_RECORD',
98
- kind,
99
- name,
100
- recordId: key,
101
- edits: record,
102
- meta: {
103
- undo: undefined
104
- }
105
- });
106
- });
107
- }
108
- } else {
109
- if (query !== undefined && query._fields) {
110
- // If requesting specific fields, items and query association to said
111
- // records are stored by ID reference. Thus, fields must always include
112
- // the ID.
113
- query = {
114
- ...query,
115
- _fields: [...new Set([...(getNormalizedCommaSeparable(query._fields) || []), entityConfig.key || DEFAULT_ENTITY_KEY])].join()
116
- };
117
- }
118
- if (query !== undefined && query._fields) {
119
- // The resolution cache won't consider query as reusable based on the
120
- // fields, so it's tested here, prior to initiating the REST request,
121
- // and without causing `getEntityRecord` resolution to occur.
122
- const hasRecord = select.hasEntityRecord(kind, name, key, query);
123
- if (hasRecord) {
124
- return;
125
- }
126
- }
127
- const path = addQueryArgs(entityConfig.baseURL + (key ? '/' + key : ''), {
128
- ...entityConfig.baseURLParams,
129
- ...query
130
- });
131
- const response = await apiFetch({
132
- path,
133
- parse: false
134
- });
135
- const record = await response.json();
136
- const permissions = getUserPermissionsFromAllowHeader(response.headers?.get('allow'));
137
- const canUserResolutionsArgs = [];
138
- const receiveUserPermissionArgs = {};
139
- for (const action of ALLOWED_RESOURCE_ACTIONS) {
140
- receiveUserPermissionArgs[getUserPermissionCacheKey(action, {
141
- kind,
142
- name,
143
- id: key
144
- })] = permissions[action];
145
- canUserResolutionsArgs.push([action, {
146
- kind,
147
- name,
148
- id: key
149
- }]);
101
+ await syncManager.load(
102
+ entityConfig.syncConfig,
103
+ objectType,
104
+ objectId,
105
+ recordWithTransients,
106
+ {
107
+ // Handle edits sourced from the sync manager.
108
+ editRecord: (edits) => {
109
+ if (!Object.keys(edits).length) {
110
+ return;
111
+ }
112
+ dispatch({
113
+ type: "EDIT_ENTITY_RECORD",
114
+ kind,
115
+ name,
116
+ recordId: key,
117
+ edits,
118
+ meta: {
119
+ undo: void 0
120
+ }
121
+ });
122
+ },
123
+ // Get the current entity record (with edits)
124
+ getEditedRecord: async () => await resolveSelect.getEditedEntityRecord(
125
+ kind,
126
+ name,
127
+ key
128
+ )
129
+ }
130
+ );
150
131
  }
151
- registry.batch(() => {
152
- dispatch.receiveEntityRecords(kind, name, record, query);
153
- dispatch.receiveUserPermissions(receiveUserPermissionArgs);
154
- dispatch.finishResolutions('canUser', canUserResolutionsArgs);
155
- });
156
132
  }
133
+ registry.batch(() => {
134
+ dispatch.receiveEntityRecords(kind, name, record, query);
135
+ dispatch.receiveUserPermissions(receiveUserPermissionArgs);
136
+ dispatch.finishResolutions("canUser", canUserResolutionsArgs);
137
+ });
157
138
  } finally {
158
139
  dispatch.__unstableReleaseStoreLock(lock);
159
140
  }
160
141
  };
161
- export const getTemplateAutoDraftId = staticTemplateId => async ({
162
- resolveSelect,
163
- dispatch
164
- }) => {
165
- const record = await resolveSelect.getEntityRecord('postType', 'wp_registered_template', staticTemplateId);
166
- const autoDraft = await dispatch.saveEntityRecord('postType', 'wp_template', {
167
- ...record,
168
- id: undefined,
169
- type: 'wp_template',
170
- status: 'auto-draft'
171
- });
172
- await dispatch.receiveTemplateAutoDraftId(staticTemplateId, autoDraft.id);
142
+ getEntityRecord.shouldInvalidate = (action, kind, name) => {
143
+ return kind === "root" && name === "site" && (action.type === "RECEIVE_ITEMS" && // Making sure persistedEdits is set seems to be the only way of
144
+ // knowing whether it's an update or fetch. Only an update would
145
+ // have persistedEdits.
146
+ action.persistedEdits && action.persistedEdits.status !== "auto-draft" || action.type === "REMOVE_ITEMS") && action.kind === "postType" && action.name === "wp_template";
173
147
  };
174
-
175
- /**
176
- * Requests an entity's record from the REST API.
177
- */
178
- export const getRawEntityRecord = forwardResolver('getEntityRecord');
179
-
180
- /**
181
- * Requests an entity's record from the REST API.
182
- */
183
- export const getEditedEntityRecord = forwardResolver('getEntityRecord');
184
-
185
- /**
186
- * Requests the entity's records from the REST API.
187
- *
188
- * @param {string} kind Entity kind.
189
- * @param {string} name Entity name.
190
- * @param {?Object} query Query Object. If requesting specific fields, fields
191
- * must always include the ID.
192
- */
193
- export const getEntityRecords = (kind, name, query = {}) => async ({
194
- dispatch,
195
- registry,
196
- resolveSelect
197
- }) => {
148
+ const getTemplateAutoDraftId = (staticTemplateId) => async ({ resolveSelect, dispatch }) => {
149
+ const record = await resolveSelect.getEntityRecord(
150
+ "postType",
151
+ "wp_registered_template",
152
+ staticTemplateId
153
+ );
154
+ const autoDraft = await dispatch.saveEntityRecord(
155
+ "postType",
156
+ "wp_template",
157
+ {
158
+ ...record,
159
+ id: void 0,
160
+ type: "wp_template",
161
+ status: "auto-draft"
162
+ }
163
+ );
164
+ await dispatch.receiveTemplateAutoDraftId(
165
+ staticTemplateId,
166
+ autoDraft.id
167
+ );
168
+ };
169
+ const getRawEntityRecord = forwardResolver("getEntityRecord");
170
+ const getEditedEntityRecord = forwardResolver("getEntityRecord");
171
+ const getEntityRecords = (kind, name, query = {}) => async ({ dispatch, registry, resolveSelect }) => {
198
172
  const configs = await resolveSelect.getEntitiesConfig(kind);
199
- const entityConfig = configs.find(config => config.name === name && config.kind === kind);
173
+ const entityConfig = configs.find(
174
+ (config) => config.name === name && config.kind === kind
175
+ );
200
176
  if (!entityConfig) {
201
177
  return;
202
178
  }
203
- const lock = await dispatch.__unstableAcquireStoreLock(STORE_NAME, ['entities', 'records', kind, name], {
204
- exclusive: false
205
- });
206
-
207
- // Keep a copy of the original query for later use in getResolutionsArgs.
208
- // The query object may be modified below (for example, when _fields is
209
- // specified), but we want to use the original query when marking
210
- // resolutions as finished.
211
- const rawQuery = {
212
- ...query
213
- };
179
+ const lock = await dispatch.__unstableAcquireStoreLock(
180
+ STORE_NAME,
181
+ ["entities", "records", kind, name],
182
+ { exclusive: false }
183
+ );
184
+ const rawQuery = { ...query };
214
185
  const key = entityConfig.key || DEFAULT_ENTITY_KEY;
215
186
  function getResolutionsArgs(records, recordsQuery) {
216
- const queryArgs = Object.fromEntries(Object.entries(recordsQuery).filter(([k, v]) => {
217
- return ['context', '_fields'].includes(k) && !!v;
218
- }));
219
- return records.filter(record => record?.[key]).map(record => [kind, name, record[key], Object.keys(queryArgs).length > 0 ? queryArgs : undefined]);
187
+ const queryArgs = Object.fromEntries(
188
+ Object.entries(recordsQuery).filter(([k, v]) => {
189
+ return ["context", "_fields"].includes(k) && !!v;
190
+ })
191
+ );
192
+ return records.filter((record) => record?.[key]).map((record) => [
193
+ kind,
194
+ name,
195
+ record[key],
196
+ Object.keys(queryArgs).length > 0 ? queryArgs : void 0
197
+ ]);
220
198
  }
221
199
  try {
222
200
  if (query._fields) {
223
- // If requesting specific fields, items and query association to said
224
- // records are stored by ID reference. Thus, fields must always include
225
- // the ID.
226
201
  query = {
227
202
  ...query,
228
- _fields: [...new Set([...(getNormalizedCommaSeparable(query._fields) || []), key])].join()
203
+ _fields: [
204
+ .../* @__PURE__ */ new Set([
205
+ ...getNormalizedCommaSeparable(query._fields) || [],
206
+ key
207
+ ])
208
+ ].join()
229
209
  };
230
210
  }
231
- const path = addQueryArgs(entityConfig.baseURL, {
211
+ let { baseURL } = entityConfig;
212
+ const { combinedTemplates = true } = query;
213
+ if (kind === "postType" && name === "wp_template" && combinedTemplates) {
214
+ baseURL = baseURL.slice(0, baseURL.lastIndexOf("/")) + "/templates";
215
+ }
216
+ const path = addQueryArgs(baseURL, {
232
217
  ...entityConfig.baseURLParams,
233
218
  ...query
234
219
  });
235
- let records = [],
236
- meta;
220
+ let records = [], meta;
237
221
  if (entityConfig.supportsPagination && query.per_page !== -1) {
238
- const response = await apiFetch({
239
- path,
240
- parse: false
241
- });
222
+ const response = await apiFetch({ path, parse: false });
242
223
  records = Object.values(await response.json());
243
224
  meta = {
244
- totalItems: parseInt(response.headers.get('X-WP-Total')),
245
- totalPages: parseInt(response.headers.get('X-WP-TotalPages'))
225
+ totalItems: parseInt(
226
+ response.headers.get("X-WP-Total")
227
+ ),
228
+ totalPages: parseInt(
229
+ response.headers.get("X-WP-TotalPages")
230
+ )
246
231
  };
247
232
  } else if (query.per_page === -1 && query[RECEIVE_INTERMEDIATE_RESULTS] === true) {
248
233
  let page = 1;
249
234
  let totalPages;
250
235
  do {
251
236
  const response = await apiFetch({
252
- path: addQueryArgs(path, {
253
- page,
254
- per_page: 100
255
- }),
237
+ path: addQueryArgs(path, { page, per_page: 100 }),
256
238
  parse: false
257
239
  });
258
240
  const pageRecords = Object.values(await response.json());
259
- totalPages = parseInt(response.headers.get('X-WP-TotalPages'));
241
+ totalPages = parseInt(
242
+ response.headers.get("X-WP-TotalPages")
243
+ );
260
244
  if (!meta) {
261
245
  meta = {
262
- totalItems: parseInt(response.headers.get('X-WP-Total')),
246
+ totalItems: parseInt(
247
+ response.headers.get("X-WP-Total")
248
+ ),
263
249
  totalPages: 1
264
250
  };
265
251
  }
266
252
  records.push(...pageRecords);
267
253
  registry.batch(() => {
268
- dispatch.receiveEntityRecords(kind, name, records, query, false, undefined, meta);
269
- dispatch.finishResolutions('getEntityRecord', getResolutionsArgs(pageRecords, rawQuery));
254
+ dispatch.receiveEntityRecords(
255
+ kind,
256
+ name,
257
+ records,
258
+ query,
259
+ false,
260
+ void 0,
261
+ meta
262
+ );
263
+ dispatch.finishResolutions(
264
+ "getEntityRecord",
265
+ getResolutionsArgs(pageRecords, rawQuery)
266
+ );
270
267
  });
271
268
  page++;
272
269
  } while (page <= totalPages);
273
270
  } else {
274
- records = Object.values(await apiFetch({
275
- path
276
- }));
271
+ records = Object.values(await apiFetch({ path }));
277
272
  meta = {
278
273
  totalItems: records.length,
279
274
  totalPages: 1
280
275
  };
281
276
  }
282
-
283
- // If we request fields but the result doesn't contain the fields,
284
- // explicitly set these fields as "undefined"
285
- // that way we consider the query "fulfilled".
286
277
  if (query._fields) {
287
- records = records.map(record => {
288
- query._fields.split(',').forEach(field => {
278
+ records = records.map((record) => {
279
+ query._fields.split(",").forEach((field) => {
289
280
  if (!record.hasOwnProperty(field)) {
290
- record[field] = undefined;
281
+ record[field] = void 0;
291
282
  }
292
283
  });
293
284
  return record;
294
285
  });
295
286
  }
296
287
  registry.batch(() => {
297
- dispatch.receiveEntityRecords(kind, name, records, query, false, undefined, meta);
298
- const targetHints = records.filter(record => !!record?.[key] && !!record?._links?.self?.[0]?.targetHints?.allow).map(record => ({
288
+ dispatch.receiveEntityRecords(
289
+ kind,
290
+ name,
291
+ records,
292
+ query,
293
+ false,
294
+ void 0,
295
+ meta
296
+ );
297
+ const targetHints = records.filter(
298
+ (record) => !!record?.[key] && !!record?._links?.self?.[0]?.targetHints?.allow
299
+ ).map((record) => ({
299
300
  id: record[key],
300
- permissions: getUserPermissionsFromAllowHeader(record._links.self[0].targetHints.allow)
301
+ permissions: getUserPermissionsFromAllowHeader(
302
+ record._links.self[0].targetHints.allow
303
+ )
301
304
  }));
302
305
  const canUserResolutionsArgs = [];
303
306
  const receiveUserPermissionArgs = {};
304
307
  for (const targetHint of targetHints) {
305
308
  for (const action of ALLOWED_RESOURCE_ACTIONS) {
306
- canUserResolutionsArgs.push([action, {
307
- kind,
308
- name,
309
- id: targetHint.id
310
- }]);
309
+ canUserResolutionsArgs.push([
310
+ action,
311
+ { kind, name, id: targetHint.id }
312
+ ]);
311
313
  receiveUserPermissionArgs[getUserPermissionCacheKey(action, {
312
314
  kind,
313
315
  name,
@@ -316,10 +318,18 @@ export const getEntityRecords = (kind, name, query = {}) => async ({
316
318
  }
317
319
  }
318
320
  if (targetHints.length > 0) {
319
- dispatch.receiveUserPermissions(receiveUserPermissionArgs);
320
- dispatch.finishResolutions('canUser', canUserResolutionsArgs);
321
+ dispatch.receiveUserPermissions(
322
+ receiveUserPermissionArgs
323
+ );
324
+ dispatch.finishResolutions(
325
+ "canUser",
326
+ canUserResolutionsArgs
327
+ );
321
328
  }
322
- dispatch.finishResolutions('getEntityRecord', getResolutionsArgs(records, rawQuery));
329
+ dispatch.finishResolutions(
330
+ "getEntityRecord",
331
+ getResolutionsArgs(records, rawQuery)
332
+ );
323
333
  dispatch.__unstableReleaseStoreLock(lock);
324
334
  });
325
335
  } catch (e) {
@@ -327,165 +337,99 @@ export const getEntityRecords = (kind, name, query = {}) => async ({
327
337
  }
328
338
  };
329
339
  getEntityRecords.shouldInvalidate = (action, kind, name) => {
330
- return (action.type === 'RECEIVE_ITEMS' || action.type === 'REMOVE_ITEMS') && action.invalidateCache && kind === action.kind && name === action.name;
340
+ return (action.type === "RECEIVE_ITEMS" || action.type === "REMOVE_ITEMS") && action.invalidateCache && kind === action.kind && name === action.name;
331
341
  };
332
-
333
- /**
334
- * Requests the total number of entity records.
335
- */
336
- export const getEntityRecordsTotalItems = forwardResolver('getEntityRecords');
337
-
338
- /**
339
- * Requests the number of available pages for the given query.
340
- */
341
- export const getEntityRecordsTotalPages = forwardResolver('getEntityRecords');
342
-
343
- /**
344
- * Requests the current theme.
345
- */
346
- export const getCurrentTheme = () => async ({
347
- dispatch,
348
- resolveSelect
349
- }) => {
350
- const activeThemes = await resolveSelect.getEntityRecords('root', 'theme', {
351
- status: 'active'
352
- });
342
+ const getEntityRecordsTotalItems = forwardResolver("getEntityRecords");
343
+ const getEntityRecordsTotalPages = forwardResolver("getEntityRecords");
344
+ const getCurrentTheme = () => async ({ dispatch, resolveSelect }) => {
345
+ const activeThemes = await resolveSelect.getEntityRecords(
346
+ "root",
347
+ "theme",
348
+ { status: "active" }
349
+ );
353
350
  dispatch.receiveCurrentTheme(activeThemes[0]);
354
351
  };
355
-
356
- /**
357
- * Requests theme supports data from the index.
358
- */
359
- export const getThemeSupports = forwardResolver('getCurrentTheme');
360
-
361
- /**
362
- * Requests a preview from the Embed API.
363
- *
364
- * @param {string} url URL to get the preview for.
365
- */
366
- export const getEmbedPreview = url => async ({
367
- dispatch
368
- }) => {
352
+ const getThemeSupports = forwardResolver("getCurrentTheme");
353
+ const getEmbedPreview = (url) => async ({ dispatch }) => {
369
354
  try {
370
355
  const embedProxyResponse = await apiFetch({
371
- path: addQueryArgs('/oembed/1.0/proxy', {
372
- url
373
- })
356
+ path: addQueryArgs("/oembed/1.0/proxy", { url })
374
357
  });
375
358
  dispatch.receiveEmbedPreview(url, embedProxyResponse);
376
359
  } catch (error) {
377
- // Embed API 404s if the URL cannot be embedded, so we have to catch the error from the apiRequest here.
378
360
  dispatch.receiveEmbedPreview(url, false);
379
361
  }
380
362
  };
381
-
382
- /**
383
- * Checks whether the current user can perform the given action on the given
384
- * REST resource.
385
- *
386
- * @param {string} requestedAction Action to check. One of: 'create', 'read', 'update',
387
- * 'delete'.
388
- * @param {string|Object} resource Entity resource to check. Accepts entity object `{ kind: 'postType', name: 'attachment', id: 1 }`
389
- * or REST base as a string - `media`.
390
- * @param {?string} id ID of the rest resource to check.
391
- */
392
- export const canUser = (requestedAction, resource, id) => async ({
393
- dispatch,
394
- registry,
395
- resolveSelect
396
- }) => {
363
+ const canUser = (requestedAction, resource, id) => async ({ dispatch, registry, resolveSelect }) => {
397
364
  if (!ALLOWED_RESOURCE_ACTIONS.includes(requestedAction)) {
398
365
  throw new Error(`'${requestedAction}' is not a valid action.`);
399
366
  }
400
- const {
401
- hasStartedResolution
402
- } = registry.select(STORE_NAME);
403
-
404
- // Prevent resolving the same resource twice.
367
+ const { hasStartedResolution } = registry.select(STORE_NAME);
405
368
  for (const relatedAction of ALLOWED_RESOURCE_ACTIONS) {
406
369
  if (relatedAction === requestedAction) {
407
370
  continue;
408
371
  }
409
- const isAlreadyResolving = hasStartedResolution('canUser', [relatedAction, resource, id]);
372
+ const isAlreadyResolving = hasStartedResolution("canUser", [
373
+ relatedAction,
374
+ resource,
375
+ id
376
+ ]);
410
377
  if (isAlreadyResolving) {
411
378
  return;
412
379
  }
413
380
  }
414
381
  let resourcePath = null;
415
- if (typeof resource === 'object') {
382
+ if (typeof resource === "object") {
416
383
  if (!resource.kind || !resource.name) {
417
- throw new Error('The entity resource object is not valid.');
384
+ throw new Error("The entity resource object is not valid.");
418
385
  }
419
- const configs = await resolveSelect.getEntitiesConfig(resource.kind);
420
- const entityConfig = configs.find(config => config.name === resource.name && config.kind === resource.kind);
386
+ const configs = await resolveSelect.getEntitiesConfig(
387
+ resource.kind
388
+ );
389
+ const entityConfig = configs.find(
390
+ (config) => config.name === resource.name && config.kind === resource.kind
391
+ );
421
392
  if (!entityConfig) {
422
393
  return;
423
394
  }
424
- resourcePath = entityConfig.baseURL + (resource.id ? '/' + resource.id : '');
395
+ resourcePath = entityConfig.baseURL + (resource.id ? "/" + resource.id : "");
425
396
  } else {
426
- resourcePath = `/wp/v2/${resource}` + (id ? '/' + id : '');
397
+ resourcePath = `/wp/v2/${resource}` + (id ? "/" + id : "");
427
398
  }
428
399
  let response;
429
400
  try {
430
401
  response = await apiFetch({
431
402
  path: resourcePath,
432
- method: 'OPTIONS',
403
+ method: "OPTIONS",
433
404
  parse: false
434
405
  });
435
406
  } catch (error) {
436
- // Do nothing if our OPTIONS request comes back with an API error (4xx or
437
- // 5xx). The previously determined isAllowed value will remain in the store.
438
407
  return;
439
408
  }
440
-
441
- // Optional chaining operator is used here because the API requests don't
442
- // return the expected result in the React native version. Instead, API requests
443
- // only return the result, without including response properties like the headers.
444
- const permissions = getUserPermissionsFromAllowHeader(response.headers?.get('allow'));
409
+ const permissions = getUserPermissionsFromAllowHeader(
410
+ response.headers?.get("allow")
411
+ );
445
412
  registry.batch(() => {
446
413
  for (const action of ALLOWED_RESOURCE_ACTIONS) {
447
414
  const key = getUserPermissionCacheKey(action, resource, id);
448
415
  dispatch.receiveUserPermission(key, permissions[action]);
449
-
450
- // Mark related action resolutions as finished.
451
416
  if (action !== requestedAction) {
452
- dispatch.finishResolution('canUser', [action, resource, id]);
417
+ dispatch.finishResolution("canUser", [
418
+ action,
419
+ resource,
420
+ id
421
+ ]);
453
422
  }
454
423
  }
455
424
  });
456
425
  };
457
-
458
- /**
459
- * Checks whether the current user can perform the given action on the given
460
- * REST resource.
461
- *
462
- * @param {string} kind Entity kind.
463
- * @param {string} name Entity name.
464
- * @param {number|string} recordId Record's id.
465
- */
466
- export const canUserEditEntityRecord = (kind, name, recordId) => async ({
467
- dispatch
468
- }) => {
469
- await dispatch(canUser('update', {
470
- kind,
471
- name,
472
- id: recordId
473
- }));
426
+ const canUserEditEntityRecord = (kind, name, recordId) => async ({ dispatch }) => {
427
+ await dispatch(canUser("update", { kind, name, id: recordId }));
474
428
  };
475
-
476
- /**
477
- * Request autosave data from the REST API.
478
- *
479
- * @param {string} postType The type of the parent post.
480
- * @param {number} postId The id of the parent post.
481
- */
482
- export const getAutosaves = (postType, postId) => async ({
483
- dispatch,
484
- resolveSelect
485
- }) => {
429
+ const getAutosaves = (postType, postId) => async ({ dispatch, resolveSelect }) => {
486
430
  const {
487
431
  rest_base: restBase,
488
- rest_namespace: restNamespace = 'wp/v2',
432
+ rest_namespace: restNamespace = "wp/v2",
489
433
  supports
490
434
  } = await resolveSelect.getPostType(postType);
491
435
  if (!supports?.autosave) {
@@ -498,131 +442,107 @@ export const getAutosaves = (postType, postId) => async ({
498
442
  dispatch.receiveAutosaves(postId, autosaves);
499
443
  }
500
444
  };
501
-
502
- /**
503
- * Request autosave data from the REST API.
504
- *
505
- * This resolver exists to ensure the underlying autosaves are fetched via
506
- * `getAutosaves` when a call to the `getAutosave` selector is made.
507
- *
508
- * @param {string} postType The type of the parent post.
509
- * @param {number} postId The id of the parent post.
510
- */
511
- export const getAutosave = (postType, postId) => async ({
512
- resolveSelect
513
- }) => {
445
+ const getAutosave = (postType, postId) => async ({ resolveSelect }) => {
514
446
  await resolveSelect.getAutosaves(postType, postId);
515
447
  };
516
- export const __experimentalGetCurrentGlobalStylesId = () => async ({
517
- dispatch,
518
- resolveSelect
519
- }) => {
520
- const activeThemes = await resolveSelect.getEntityRecords('root', 'theme', {
521
- status: 'active'
522
- });
523
- const globalStylesURL = activeThemes?.[0]?._links?.['wp:user-global-styles']?.[0]?.href;
448
+ const __experimentalGetCurrentGlobalStylesId = () => async ({ dispatch, resolveSelect }) => {
449
+ const activeThemes = await resolveSelect.getEntityRecords(
450
+ "root",
451
+ "theme",
452
+ { status: "active" }
453
+ );
454
+ const globalStylesURL = activeThemes?.[0]?._links?.["wp:user-global-styles"]?.[0]?.href;
524
455
  if (!globalStylesURL) {
525
456
  return;
526
457
  }
527
-
528
- // Regex matches the ID at the end of a URL or immediately before
529
- // the query string.
530
458
  const matches = globalStylesURL.match(/\/(\d+)(?:\?|$)/);
531
459
  const id = matches ? Number(matches[1]) : null;
532
460
  if (id) {
533
461
  dispatch.__experimentalReceiveCurrentGlobalStylesId(id);
534
462
  }
535
463
  };
536
- export const __experimentalGetCurrentThemeBaseGlobalStyles = () => async ({
537
- resolveSelect,
538
- dispatch
539
- }) => {
464
+ const __experimentalGetCurrentThemeBaseGlobalStyles = () => async ({ resolveSelect, dispatch }) => {
540
465
  const currentTheme = await resolveSelect.getCurrentTheme();
541
- // Please adjust the preloaded requests if this changes!
542
466
  const themeGlobalStyles = await apiFetch({
543
467
  path: `/wp/v2/global-styles/themes/${currentTheme.stylesheet}?context=view`
544
468
  });
545
- dispatch.__experimentalReceiveThemeBaseGlobalStyles(currentTheme.stylesheet, themeGlobalStyles);
469
+ dispatch.__experimentalReceiveThemeBaseGlobalStyles(
470
+ currentTheme.stylesheet,
471
+ themeGlobalStyles
472
+ );
546
473
  };
547
- export const __experimentalGetCurrentThemeGlobalStylesVariations = () => async ({
548
- resolveSelect,
549
- dispatch
550
- }) => {
474
+ const __experimentalGetCurrentThemeGlobalStylesVariations = () => async ({ resolveSelect, dispatch }) => {
551
475
  const currentTheme = await resolveSelect.getCurrentTheme();
552
- // Please adjust the preloaded requests if this changes!
553
476
  const variations = await apiFetch({
554
477
  path: `/wp/v2/global-styles/themes/${currentTheme.stylesheet}/variations?context=view`
555
478
  });
556
- dispatch.__experimentalReceiveThemeGlobalStyleVariations(currentTheme.stylesheet, variations);
479
+ dispatch.__experimentalReceiveThemeGlobalStyleVariations(
480
+ currentTheme.stylesheet,
481
+ variations
482
+ );
557
483
  };
558
-
559
- /**
560
- * Fetches and returns the revisions of the current global styles theme.
561
- */
562
- export const getCurrentThemeGlobalStylesRevisions = () => async ({
563
- resolveSelect,
564
- dispatch
565
- }) => {
484
+ const getCurrentThemeGlobalStylesRevisions = () => async ({ resolveSelect, dispatch }) => {
566
485
  const globalStylesId = await resolveSelect.__experimentalGetCurrentGlobalStylesId();
567
- const record = globalStylesId ? await resolveSelect.getEntityRecord('root', 'globalStyles', globalStylesId) : undefined;
568
- const revisionsURL = record?._links?.['version-history']?.[0]?.href;
486
+ const record = globalStylesId ? await resolveSelect.getEntityRecord(
487
+ "root",
488
+ "globalStyles",
489
+ globalStylesId
490
+ ) : void 0;
491
+ const revisionsURL = record?._links?.["version-history"]?.[0]?.href;
569
492
  if (revisionsURL) {
570
493
  const resetRevisions = await apiFetch({
571
494
  url: revisionsURL
572
495
  });
573
- const revisions = resetRevisions?.map(revision => Object.fromEntries(Object.entries(revision).map(([key, value]) => [camelCase(key), value])));
574
- dispatch.receiveThemeGlobalStyleRevisions(globalStylesId, revisions);
496
+ const revisions = resetRevisions?.map(
497
+ (revision) => Object.fromEntries(
498
+ Object.entries(revision).map(([key, value]) => [
499
+ camelCase(key),
500
+ value
501
+ ])
502
+ )
503
+ );
504
+ dispatch.receiveThemeGlobalStyleRevisions(
505
+ globalStylesId,
506
+ revisions
507
+ );
575
508
  }
576
509
  };
577
- getCurrentThemeGlobalStylesRevisions.shouldInvalidate = action => {
578
- return action.type === 'SAVE_ENTITY_RECORD_FINISH' && action.kind === 'root' && !action.error && action.name === 'globalStyles';
510
+ getCurrentThemeGlobalStylesRevisions.shouldInvalidate = (action) => {
511
+ return action.type === "SAVE_ENTITY_RECORD_FINISH" && action.kind === "root" && !action.error && action.name === "globalStyles";
579
512
  };
580
- export const getBlockPatterns = () => async ({
581
- dispatch
582
- }) => {
513
+ const getBlockPatterns = () => async ({ dispatch }) => {
583
514
  const patterns = await fetchBlockPatterns();
584
- dispatch({
585
- type: 'RECEIVE_BLOCK_PATTERNS',
586
- patterns
587
- });
515
+ dispatch({ type: "RECEIVE_BLOCK_PATTERNS", patterns });
588
516
  };
589
- export const getBlockPatternCategories = () => async ({
590
- dispatch
591
- }) => {
517
+ const getBlockPatternCategories = () => async ({ dispatch }) => {
592
518
  const categories = await apiFetch({
593
- path: '/wp/v2/block-patterns/categories'
594
- });
595
- dispatch({
596
- type: 'RECEIVE_BLOCK_PATTERN_CATEGORIES',
597
- categories
519
+ path: "/wp/v2/block-patterns/categories"
598
520
  });
521
+ dispatch({ type: "RECEIVE_BLOCK_PATTERN_CATEGORIES", categories });
599
522
  };
600
- export const getUserPatternCategories = () => async ({
601
- dispatch,
602
- resolveSelect
603
- }) => {
604
- const patternCategories = await resolveSelect.getEntityRecords('taxonomy', 'wp_pattern_category', {
605
- per_page: -1,
606
- _fields: 'id,name,description,slug',
607
- context: 'view'
608
- });
609
- const mappedPatternCategories = patternCategories?.map(userCategory => ({
523
+ const getUserPatternCategories = () => async ({ dispatch, resolveSelect }) => {
524
+ const patternCategories = await resolveSelect.getEntityRecords(
525
+ "taxonomy",
526
+ "wp_pattern_category",
527
+ {
528
+ per_page: -1,
529
+ _fields: "id,name,description,slug",
530
+ context: "view"
531
+ }
532
+ );
533
+ const mappedPatternCategories = patternCategories?.map((userCategory) => ({
610
534
  ...userCategory,
611
535
  label: decodeEntities(userCategory.name),
612
536
  name: userCategory.slug
613
537
  })) || [];
614
538
  dispatch({
615
- type: 'RECEIVE_USER_PATTERN_CATEGORIES',
539
+ type: "RECEIVE_USER_PATTERN_CATEGORIES",
616
540
  patternCategories: mappedPatternCategories
617
541
  });
618
542
  };
619
- export const getNavigationFallbackId = () => async ({
620
- dispatch,
621
- select,
622
- registry
623
- }) => {
543
+ const getNavigationFallbackId = () => async ({ dispatch, select, registry }) => {
624
544
  const fallback = await apiFetch({
625
- path: addQueryArgs('/wp-block-editor/v1/navigation-fallback', {
545
+ path: addQueryArgs("/wp-block-editor/v1/navigation-fallback", {
626
546
  _embed: true
627
547
  })
628
548
  });
@@ -632,207 +552,186 @@ export const getNavigationFallbackId = () => async ({
632
552
  if (!record) {
633
553
  return;
634
554
  }
635
-
636
- // If the fallback is already in the store, don't invalidate navigation queries.
637
- // Otherwise, invalidate the cache for the scenario where there were no Navigation
638
- // posts in the state and the fallback created one.
639
- const existingFallbackEntityRecord = select.getEntityRecord('postType', 'wp_navigation', fallback.id);
555
+ const existingFallbackEntityRecord = select.getEntityRecord(
556
+ "postType",
557
+ "wp_navigation",
558
+ fallback.id
559
+ );
640
560
  const invalidateNavigationQueries = !existingFallbackEntityRecord;
641
- dispatch.receiveEntityRecords('postType', 'wp_navigation', record, undefined, invalidateNavigationQueries);
642
-
643
- // Resolve to avoid further network requests.
644
- dispatch.finishResolution('getEntityRecord', ['postType', 'wp_navigation', fallback.id]);
561
+ dispatch.receiveEntityRecords(
562
+ "postType",
563
+ "wp_navigation",
564
+ record,
565
+ void 0,
566
+ invalidateNavigationQueries
567
+ );
568
+ dispatch.finishResolution("getEntityRecord", [
569
+ "postType",
570
+ "wp_navigation",
571
+ fallback.id
572
+ ]);
645
573
  });
646
574
  };
647
- export const getDefaultTemplateId = query => async ({
648
- dispatch,
649
- registry,
650
- resolveSelect
651
- }) => {
575
+ const getDefaultTemplateId = (query) => async ({ dispatch, registry, resolveSelect }) => {
652
576
  const template = await apiFetch({
653
- path: addQueryArgs('/wp/v2/templates/lookup', query)
577
+ path: addQueryArgs("/wp/v2/templates/lookup", query)
654
578
  });
655
- // Wait for the the entities config to be loaded, otherwise receiving
656
- // the template as an entity will not work.
657
- await resolveSelect.getEntitiesConfig('postType');
579
+ await resolveSelect.getEntitiesConfig("postType");
658
580
  const id = template?.wp_id || template?.id;
659
- // Endpoint may return an empty object if no template is found.
660
581
  if (id) {
661
582
  template.id = id;
662
- template.type = typeof id === 'string' ? 'wp_registered_template' : 'wp_template';
583
+ template.type = typeof id === "string" ? "wp_registered_template" : "wp_template";
663
584
  registry.batch(() => {
664
585
  dispatch.receiveDefaultTemplateId(query, id);
665
- dispatch.receiveEntityRecords('postType', template.type, [template]);
666
- // Avoid further network requests.
667
- dispatch.finishResolution('getEntityRecord', ['postType', template.type, id]);
586
+ dispatch.receiveEntityRecords("postType", template.type, [
587
+ template
588
+ ]);
589
+ dispatch.finishResolution("getEntityRecord", [
590
+ "postType",
591
+ template.type,
592
+ id
593
+ ]);
668
594
  });
669
595
  }
670
596
  };
671
- getDefaultTemplateId.shouldInvalidate = action => {
672
- return action.type === 'EDIT_ENTITY_RECORD' && action.kind === 'root' && action.name === 'site';
597
+ getDefaultTemplateId.shouldInvalidate = (action) => {
598
+ return action.type === "RECEIVE_ITEMS" && action.kind === "root" && action.name === "site";
673
599
  };
674
-
675
- /**
676
- * Requests an entity's revisions from the REST API.
677
- *
678
- * @param {string} kind Entity kind.
679
- * @param {string} name Entity name.
680
- * @param {number|string} recordKey The key of the entity record whose revisions you want to fetch.
681
- * @param {Object|undefined} query Optional object of query parameters to
682
- * include with request. If requesting specific
683
- * fields, fields must always include the ID.
684
- */
685
- export const getRevisions = (kind, name, recordKey, query = {}) => async ({
686
- dispatch,
687
- registry,
688
- resolveSelect
689
- }) => {
600
+ const getRevisions = (kind, name, recordKey, query = {}) => async ({ dispatch, registry, resolveSelect }) => {
690
601
  const configs = await resolveSelect.getEntitiesConfig(kind);
691
- const entityConfig = configs.find(config => config.name === name && config.kind === kind);
602
+ const entityConfig = configs.find(
603
+ (config) => config.name === name && config.kind === kind
604
+ );
692
605
  if (!entityConfig) {
693
606
  return;
694
607
  }
695
608
  if (query._fields) {
696
- // If requesting specific fields, items and query association to said
697
- // records are stored by ID reference. Thus, fields must always include
698
- // the ID.
699
609
  query = {
700
610
  ...query,
701
- _fields: [...new Set([...(getNormalizedCommaSeparable(query._fields) || []), entityConfig.revisionKey || DEFAULT_ENTITY_KEY])].join()
611
+ _fields: [
612
+ .../* @__PURE__ */ new Set([
613
+ ...getNormalizedCommaSeparable(query._fields) || [],
614
+ entityConfig.revisionKey || DEFAULT_ENTITY_KEY
615
+ ])
616
+ ].join()
702
617
  };
703
618
  }
704
- const path = addQueryArgs(entityConfig.getRevisionsUrl(recordKey), query);
619
+ const path = addQueryArgs(
620
+ entityConfig.getRevisionsUrl(recordKey),
621
+ query
622
+ );
705
623
  let records, response;
706
624
  const meta = {};
707
625
  const isPaginated = entityConfig.supportsPagination && query.per_page !== -1;
708
626
  try {
709
- response = await apiFetch({
710
- path,
711
- parse: !isPaginated
712
- });
627
+ response = await apiFetch({ path, parse: !isPaginated });
713
628
  } catch (error) {
714
- // Do nothing if our request comes back with an API error.
715
629
  return;
716
630
  }
717
631
  if (response) {
718
632
  if (isPaginated) {
719
633
  records = Object.values(await response.json());
720
- meta.totalItems = parseInt(response.headers.get('X-WP-Total'));
634
+ meta.totalItems = parseInt(
635
+ response.headers.get("X-WP-Total")
636
+ );
721
637
  } else {
722
638
  records = Object.values(response);
723
639
  }
724
-
725
- // If we request fields but the result doesn't contain the fields,
726
- // explicitly set these fields as "undefined"
727
- // that way we consider the query "fulfilled".
728
640
  if (query._fields) {
729
- records = records.map(record => {
730
- query._fields.split(',').forEach(field => {
641
+ records = records.map((record) => {
642
+ query._fields.split(",").forEach((field) => {
731
643
  if (!record.hasOwnProperty(field)) {
732
- record[field] = undefined;
644
+ record[field] = void 0;
733
645
  }
734
646
  });
735
647
  return record;
736
648
  });
737
649
  }
738
650
  registry.batch(() => {
739
- dispatch.receiveRevisions(kind, name, recordKey, records, query, false, meta);
740
-
741
- // When requesting all fields, the list of results can be used to
742
- // resolve the `getRevision` selector in addition to `getRevisions`.
651
+ dispatch.receiveRevisions(
652
+ kind,
653
+ name,
654
+ recordKey,
655
+ records,
656
+ query,
657
+ false,
658
+ meta
659
+ );
743
660
  if (!query?._fields && !query.context) {
744
661
  const key = entityConfig.key || DEFAULT_ENTITY_KEY;
745
- const resolutionsArgs = records.filter(record => record[key]).map(record => [kind, name, recordKey, record[key]]);
746
- dispatch.finishResolutions('getRevision', resolutionsArgs);
662
+ const resolutionsArgs = records.filter((record) => record[key]).map((record) => [
663
+ kind,
664
+ name,
665
+ recordKey,
666
+ record[key]
667
+ ]);
668
+ dispatch.finishResolutions(
669
+ "getRevision",
670
+ resolutionsArgs
671
+ );
747
672
  }
748
673
  });
749
674
  }
750
675
  };
751
-
752
- // Invalidate cache when a new revision is created.
753
- getRevisions.shouldInvalidate = (action, kind, name, recordKey) => action.type === 'SAVE_ENTITY_RECORD_FINISH' && name === action.name && kind === action.kind && !action.error && recordKey === action.recordId;
754
-
755
- /**
756
- * Requests a specific Entity revision from the REST API.
757
- *
758
- * @param {string} kind Entity kind.
759
- * @param {string} name Entity name.
760
- * @param {number|string} recordKey The key of the entity record whose revisions you want to fetch.
761
- * @param {number|string} revisionKey The revision's key.
762
- * @param {Object|undefined} query Optional object of query parameters to
763
- * include with request. If requesting specific
764
- * fields, fields must always include the ID.
765
- */
766
- export const getRevision = (kind, name, recordKey, revisionKey, query) => async ({
767
- dispatch,
768
- resolveSelect
769
- }) => {
676
+ getRevisions.shouldInvalidate = (action, kind, name, recordKey) => action.type === "SAVE_ENTITY_RECORD_FINISH" && name === action.name && kind === action.kind && !action.error && recordKey === action.recordId;
677
+ const getRevision = (kind, name, recordKey, revisionKey, query) => async ({ dispatch, resolveSelect }) => {
770
678
  const configs = await resolveSelect.getEntitiesConfig(kind);
771
- const entityConfig = configs.find(config => config.name === name && config.kind === kind);
679
+ const entityConfig = configs.find(
680
+ (config) => config.name === name && config.kind === kind
681
+ );
772
682
  if (!entityConfig) {
773
683
  return;
774
684
  }
775
- if (query !== undefined && query._fields) {
776
- // If requesting specific fields, items and query association to said
777
- // records are stored by ID reference. Thus, fields must always include
778
- // the ID.
685
+ if (query !== void 0 && query._fields) {
779
686
  query = {
780
687
  ...query,
781
- _fields: [...new Set([...(getNormalizedCommaSeparable(query._fields) || []), entityConfig.revisionKey || DEFAULT_ENTITY_KEY])].join()
688
+ _fields: [
689
+ .../* @__PURE__ */ new Set([
690
+ ...getNormalizedCommaSeparable(query._fields) || [],
691
+ entityConfig.revisionKey || DEFAULT_ENTITY_KEY
692
+ ])
693
+ ].join()
782
694
  };
783
695
  }
784
- const path = addQueryArgs(entityConfig.getRevisionsUrl(recordKey, revisionKey), query);
696
+ const path = addQueryArgs(
697
+ entityConfig.getRevisionsUrl(recordKey, revisionKey),
698
+ query
699
+ );
785
700
  let record;
786
701
  try {
787
- record = await apiFetch({
788
- path
789
- });
702
+ record = await apiFetch({ path });
790
703
  } catch (error) {
791
- // Do nothing if our request comes back with an API error.
792
704
  return;
793
705
  }
794
706
  if (record) {
795
707
  dispatch.receiveRevisions(kind, name, recordKey, record, query);
796
708
  }
797
709
  };
798
-
799
- /**
800
- * Requests a specific post type options from the REST API.
801
- *
802
- * @param {string} postType Post type slug.
803
- */
804
- export const getRegisteredPostMeta = postType => async ({
805
- dispatch,
806
- resolveSelect
807
- }) => {
710
+ const getRegisteredPostMeta = (postType) => async ({ dispatch, resolveSelect }) => {
808
711
  let options;
809
712
  try {
810
713
  const {
811
- rest_namespace: restNamespace = 'wp/v2',
714
+ rest_namespace: restNamespace = "wp/v2",
812
715
  rest_base: restBase
813
- } = (await resolveSelect.getPostType(postType)) || {};
716
+ } = await resolveSelect.getPostType(postType) || {};
814
717
  options = await apiFetch({
815
718
  path: `${restNamespace}/${restBase}/?context=edit`,
816
- method: 'OPTIONS'
719
+ method: "OPTIONS"
817
720
  });
818
721
  } catch (error) {
819
- // Do nothing if the request comes back with an API error.
820
722
  return;
821
723
  }
822
724
  if (options) {
823
- dispatch.receiveRegisteredPostMeta(postType, options?.schema?.properties?.meta?.properties);
725
+ dispatch.receiveRegisteredPostMeta(
726
+ postType,
727
+ options?.schema?.properties?.meta?.properties
728
+ );
824
729
  }
825
730
  };
826
-
827
- /**
828
- * Requests entity configs for the given kind from the REST API.
829
- *
830
- * @param {string} kind Entity kind.
831
- */
832
- export const getEntitiesConfig = kind => async ({
833
- dispatch
834
- }) => {
835
- const loader = additionalEntityConfigLoaders.find(l => l.kind === kind);
731
+ const getEntitiesConfig = (kind) => async ({ dispatch }) => {
732
+ const loader = additionalEntityConfigLoaders.find(
733
+ (l) => l.kind === kind
734
+ );
836
735
  if (!loader) {
837
736
  return;
838
737
  }
@@ -843,7 +742,37 @@ export const getEntitiesConfig = kind => async ({
843
742
  }
844
743
  dispatch.addEntities(configs);
845
744
  } catch {
846
- // Do nothing if the request comes back with an API error.
847
745
  }
848
746
  };
849
- //# sourceMappingURL=resolvers.js.map
747
+ export {
748
+ __experimentalGetCurrentGlobalStylesId,
749
+ __experimentalGetCurrentThemeBaseGlobalStyles,
750
+ __experimentalGetCurrentThemeGlobalStylesVariations,
751
+ canUser,
752
+ canUserEditEntityRecord,
753
+ getAuthors,
754
+ getAutosave,
755
+ getAutosaves,
756
+ getBlockPatternCategories,
757
+ getBlockPatterns,
758
+ getCurrentTheme,
759
+ getCurrentThemeGlobalStylesRevisions,
760
+ getCurrentUser,
761
+ getDefaultTemplateId,
762
+ getEditedEntityRecord,
763
+ getEmbedPreview,
764
+ getEntitiesConfig,
765
+ getEntityRecord,
766
+ getEntityRecords,
767
+ getEntityRecordsTotalItems,
768
+ getEntityRecordsTotalPages,
769
+ getNavigationFallbackId,
770
+ getRawEntityRecord,
771
+ getRegisteredPostMeta,
772
+ getRevision,
773
+ getRevisions,
774
+ getTemplateAutoDraftId,
775
+ getThemeSupports,
776
+ getUserPatternCategories
777
+ };
778
+ //# sourceMappingURL=resolvers.js.map