@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
package/build/actions.js CHANGED
@@ -1,139 +1,109 @@
1
1
  "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
- Object.defineProperty(exports, "__esModule", {
5
- value: true
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+ var actions_exports = {};
30
+ __export(actions_exports, {
31
+ __experimentalBatch: () => __experimentalBatch,
32
+ __experimentalReceiveCurrentGlobalStylesId: () => __experimentalReceiveCurrentGlobalStylesId,
33
+ __experimentalReceiveThemeBaseGlobalStyles: () => __experimentalReceiveThemeBaseGlobalStyles,
34
+ __experimentalReceiveThemeGlobalStyleVariations: () => __experimentalReceiveThemeGlobalStyleVariations,
35
+ __experimentalSaveSpecifiedEntityEdits: () => __experimentalSaveSpecifiedEntityEdits,
36
+ __unstableCreateUndoLevel: () => __unstableCreateUndoLevel,
37
+ addEntities: () => addEntities,
38
+ deleteEntityRecord: () => deleteEntityRecord,
39
+ editEntityRecord: () => editEntityRecord,
40
+ receiveAutosaves: () => receiveAutosaves,
41
+ receiveCurrentTheme: () => receiveCurrentTheme,
42
+ receiveCurrentUser: () => receiveCurrentUser,
43
+ receiveDefaultTemplateId: () => receiveDefaultTemplateId,
44
+ receiveEmbedPreview: () => receiveEmbedPreview,
45
+ receiveEntityRecords: () => receiveEntityRecords,
46
+ receiveNavigationFallbackId: () => receiveNavigationFallbackId,
47
+ receiveRevisions: () => receiveRevisions,
48
+ receiveThemeGlobalStyleRevisions: () => receiveThemeGlobalStyleRevisions,
49
+ receiveThemeSupports: () => receiveThemeSupports,
50
+ receiveUploadPermissions: () => receiveUploadPermissions,
51
+ receiveUserPermission: () => receiveUserPermission,
52
+ receiveUserPermissions: () => receiveUserPermissions,
53
+ receiveUserQuery: () => receiveUserQuery,
54
+ redo: () => redo,
55
+ saveEditedEntityRecord: () => saveEditedEntityRecord,
56
+ saveEntityRecord: () => saveEntityRecord,
57
+ undo: () => undo
6
58
  });
7
- exports.__experimentalBatch = void 0;
8
- exports.__experimentalReceiveCurrentGlobalStylesId = __experimentalReceiveCurrentGlobalStylesId;
9
- exports.__experimentalReceiveThemeBaseGlobalStyles = __experimentalReceiveThemeBaseGlobalStyles;
10
- exports.__experimentalReceiveThemeGlobalStyleVariations = __experimentalReceiveThemeGlobalStyleVariations;
11
- exports.__unstableCreateUndoLevel = exports.__experimentalSaveSpecifiedEntityEdits = void 0;
12
- exports.addEntities = addEntities;
13
- exports.editEntityRecord = exports.deleteEntityRecord = void 0;
14
- exports.receiveAutosaves = receiveAutosaves;
15
- exports.receiveCurrentTheme = receiveCurrentTheme;
16
- exports.receiveCurrentUser = receiveCurrentUser;
17
- exports.receiveDefaultTemplateId = receiveDefaultTemplateId;
18
- exports.receiveEmbedPreview = receiveEmbedPreview;
19
- exports.receiveEntityRecords = receiveEntityRecords;
20
- exports.receiveNavigationFallbackId = receiveNavigationFallbackId;
21
- exports.receiveRevisions = void 0;
22
- exports.receiveThemeGlobalStyleRevisions = receiveThemeGlobalStyleRevisions;
23
- exports.receiveThemeSupports = receiveThemeSupports;
24
- exports.receiveUploadPermissions = receiveUploadPermissions;
25
- exports.receiveUserPermission = receiveUserPermission;
26
- exports.receiveUserPermissions = receiveUserPermissions;
27
- exports.receiveUserQuery = receiveUserQuery;
28
- exports.undo = exports.saveEntityRecord = exports.saveEditedEntityRecord = exports.redo = void 0;
29
- var _es = _interopRequireDefault(require("fast-deep-equal/es6"));
30
- var _uuid = require("uuid");
31
- var _apiFetch = _interopRequireDefault(require("@wordpress/api-fetch"));
32
- var _url = require("@wordpress/url");
33
- var _deprecated = _interopRequireDefault(require("@wordpress/deprecated"));
34
- var _utils = require("./utils");
35
- var _queriedData = require("./queried-data");
36
- var _entities = require("./entities");
37
- var _batch = require("./batch");
38
- var _name = require("./name");
39
- var _sync = require("./sync");
40
- var _logEntityDeprecation = _interopRequireDefault(require("./utils/log-entity-deprecation"));
41
- /**
42
- * External dependencies
43
- */
44
-
45
- /**
46
- * WordPress dependencies
47
- */
48
-
49
- /**
50
- * Internal dependencies
51
- */
52
-
53
- /**
54
- * Returns an action object used in signalling that authors have been received.
55
- * Ignored from documentation as it's internal to the data store.
56
- *
57
- * @ignore
58
- *
59
- * @param {string} queryID Query ID.
60
- * @param {Array|Object} users Users received.
61
- *
62
- * @return {Object} Action object.
63
- */
59
+ module.exports = __toCommonJS(actions_exports);
60
+ var import_es6 = __toESM(require("fast-deep-equal/es6"));
61
+ var import_uuid = require("uuid");
62
+ var import_api_fetch = __toESM(require("@wordpress/api-fetch"));
63
+ var import_url = require("@wordpress/url");
64
+ var import_deprecated = __toESM(require("@wordpress/deprecated"));
65
+ var import_utils = require("./utils");
66
+ var import_queried_data = require("./queried-data");
67
+ var import_entities = require("./entities");
68
+ var import_batch = require("./batch");
69
+ var import_name = require("./name");
70
+ var import_sync = require("./sync");
71
+ var import_log_entity_deprecation = __toESM(require("./utils/log-entity-deprecation"));
64
72
  function receiveUserQuery(queryID, users) {
65
73
  return {
66
- type: 'RECEIVE_USER_QUERY',
74
+ type: "RECEIVE_USER_QUERY",
67
75
  users: Array.isArray(users) ? users : [users],
68
76
  queryID
69
77
  };
70
78
  }
71
-
72
- /**
73
- * Returns an action used in signalling that the current user has been received.
74
- * Ignored from documentation as it's internal to the data store.
75
- *
76
- * @ignore
77
- *
78
- * @param {Object} currentUser Current user object.
79
- *
80
- * @return {Object} Action object.
81
- */
82
79
  function receiveCurrentUser(currentUser) {
83
80
  return {
84
- type: 'RECEIVE_CURRENT_USER',
81
+ type: "RECEIVE_CURRENT_USER",
85
82
  currentUser
86
83
  };
87
84
  }
88
-
89
- /**
90
- * Returns an action object used in adding new entities.
91
- *
92
- * @param {Array} entities Entities received.
93
- *
94
- * @return {Object} Action object.
95
- */
96
85
  function addEntities(entities) {
97
86
  return {
98
- type: 'ADD_ENTITIES',
87
+ type: "ADD_ENTITIES",
99
88
  entities
100
89
  };
101
90
  }
102
-
103
- /**
104
- * Returns an action object used in signalling that entity records have been received.
105
- *
106
- * @param {string} kind Kind of the received entity record.
107
- * @param {string} name Name of the received entity record.
108
- * @param {Array|Object} records Records received.
109
- * @param {?Object} query Query Object.
110
- * @param {?boolean} invalidateCache Should invalidate query caches.
111
- * @param {?Object} edits Edits to reset.
112
- * @param {?Object} meta Meta information about pagination.
113
- * @return {Object} Action object.
114
- */
115
91
  function receiveEntityRecords(kind, name, records, query, invalidateCache = false, edits, meta) {
116
- // If we receive an auto-draft template, pretend it's already published.
117
- if (kind === 'postType' && name === 'wp_template') {
118
- records = (Array.isArray(records) ? records : [records]).map(record => record.status === 'auto-draft' ? {
119
- ...record,
120
- status: 'publish'
121
- } : record);
92
+ if (kind === "postType" && name === "wp_template") {
93
+ records = (Array.isArray(records) ? records : [records]).map(
94
+ (record) => record.status === "auto-draft" ? { ...record, status: "publish" } : record
95
+ );
122
96
  }
123
-
124
- // Auto drafts should not have titles, but some plugins rely on them so we can't filter this
125
- // on the server.
126
- if (kind === 'postType') {
127
- records = (Array.isArray(records) ? records : [records]).map(record => record.status === 'auto-draft' ? {
128
- ...record,
129
- title: ''
130
- } : record);
97
+ if (kind === "postType") {
98
+ records = (Array.isArray(records) ? records : [records]).map(
99
+ (record) => record.status === "auto-draft" ? { ...record, title: "" } : record
100
+ );
131
101
  }
132
102
  let action;
133
103
  if (query) {
134
- action = (0, _queriedData.receiveQueriedItems)(records, query, edits, meta);
104
+ action = (0, import_queried_data.receiveQueriedItems)(records, query, edits, meta);
135
105
  } else {
136
- action = (0, _queriedData.receiveItems)(records, edits, meta);
106
+ action = (0, import_queried_data.receiveItems)(records, edits, meta);
137
107
  }
138
108
  return {
139
109
  ...action,
@@ -142,197 +112,105 @@ function receiveEntityRecords(kind, name, records, query, invalidateCache = fals
142
112
  invalidateCache
143
113
  };
144
114
  }
145
-
146
- /**
147
- * Returns an action object used in signalling that the current theme has been received.
148
- * Ignored from documentation as it's internal to the data store.
149
- *
150
- * @ignore
151
- *
152
- * @param {Object} currentTheme The current theme.
153
- *
154
- * @return {Object} Action object.
155
- */
156
115
  function receiveCurrentTheme(currentTheme) {
157
116
  return {
158
- type: 'RECEIVE_CURRENT_THEME',
117
+ type: "RECEIVE_CURRENT_THEME",
159
118
  currentTheme
160
119
  };
161
120
  }
162
-
163
- /**
164
- * Returns an action object used in signalling that the current global styles id has been received.
165
- * Ignored from documentation as it's internal to the data store.
166
- *
167
- * @ignore
168
- *
169
- * @param {string} currentGlobalStylesId The current global styles id.
170
- *
171
- * @return {Object} Action object.
172
- */
173
121
  function __experimentalReceiveCurrentGlobalStylesId(currentGlobalStylesId) {
174
122
  return {
175
- type: 'RECEIVE_CURRENT_GLOBAL_STYLES_ID',
123
+ type: "RECEIVE_CURRENT_GLOBAL_STYLES_ID",
176
124
  id: currentGlobalStylesId
177
125
  };
178
126
  }
179
-
180
- /**
181
- * Returns an action object used in signalling that the theme base global styles have been received
182
- * Ignored from documentation as it's internal to the data store.
183
- *
184
- * @ignore
185
- *
186
- * @param {string} stylesheet The theme's identifier
187
- * @param {Object} globalStyles The global styles object.
188
- *
189
- * @return {Object} Action object.
190
- */
191
127
  function __experimentalReceiveThemeBaseGlobalStyles(stylesheet, globalStyles) {
192
128
  return {
193
- type: 'RECEIVE_THEME_GLOBAL_STYLES',
129
+ type: "RECEIVE_THEME_GLOBAL_STYLES",
194
130
  stylesheet,
195
131
  globalStyles
196
132
  };
197
133
  }
198
-
199
- /**
200
- * Returns an action object used in signalling that the theme global styles variations have been received.
201
- * Ignored from documentation as it's internal to the data store.
202
- *
203
- * @ignore
204
- *
205
- * @param {string} stylesheet The theme's identifier
206
- * @param {Array} variations The global styles variations.
207
- *
208
- * @return {Object} Action object.
209
- */
210
134
  function __experimentalReceiveThemeGlobalStyleVariations(stylesheet, variations) {
211
135
  return {
212
- type: 'RECEIVE_THEME_GLOBAL_STYLE_VARIATIONS',
136
+ type: "RECEIVE_THEME_GLOBAL_STYLE_VARIATIONS",
213
137
  stylesheet,
214
138
  variations
215
139
  };
216
140
  }
217
-
218
- /**
219
- * Returns an action object used in signalling that the index has been received.
220
- *
221
- * @deprecated since WP 5.9, this is not useful anymore, use the selector directly.
222
- *
223
- * @return {Object} Action object.
224
- */
225
141
  function receiveThemeSupports() {
226
- (0, _deprecated.default)("wp.data.dispatch( 'core' ).receiveThemeSupports", {
227
- since: '5.9'
142
+ (0, import_deprecated.default)("wp.data.dispatch( 'core' ).receiveThemeSupports", {
143
+ since: "5.9"
228
144
  });
229
145
  return {
230
- type: 'DO_NOTHING'
146
+ type: "DO_NOTHING"
231
147
  };
232
148
  }
233
-
234
- /**
235
- * Returns an action object used in signalling that the theme global styles CPT post revisions have been received.
236
- * Ignored from documentation as it's internal to the data store.
237
- *
238
- * @deprecated since WordPress 6.5.0. Callers should use `dispatch( 'core' ).receiveRevision` instead.
239
- *
240
- * @ignore
241
- *
242
- * @param {number} currentId The post id.
243
- * @param {Array} revisions The global styles revisions.
244
- *
245
- * @return {Object} Action object.
246
- */
247
149
  function receiveThemeGlobalStyleRevisions(currentId, revisions) {
248
- (0, _deprecated.default)("wp.data.dispatch( 'core' ).receiveThemeGlobalStyleRevisions()", {
249
- since: '6.5.0',
250
- alternative: "wp.data.dispatch( 'core' ).receiveRevisions"
251
- });
150
+ (0, import_deprecated.default)(
151
+ "wp.data.dispatch( 'core' ).receiveThemeGlobalStyleRevisions()",
152
+ {
153
+ since: "6.5.0",
154
+ alternative: "wp.data.dispatch( 'core' ).receiveRevisions"
155
+ }
156
+ );
252
157
  return {
253
- type: 'RECEIVE_THEME_GLOBAL_STYLE_REVISIONS',
158
+ type: "RECEIVE_THEME_GLOBAL_STYLE_REVISIONS",
254
159
  currentId,
255
160
  revisions
256
161
  };
257
162
  }
258
-
259
- /**
260
- * Returns an action object used in signalling that the preview data for
261
- * a given URl has been received.
262
- * Ignored from documentation as it's internal to the data store.
263
- *
264
- * @ignore
265
- *
266
- * @param {string} url URL to preview the embed for.
267
- * @param {*} preview Preview data.
268
- *
269
- * @return {Object} Action object.
270
- */
271
163
  function receiveEmbedPreview(url, preview) {
272
164
  return {
273
- type: 'RECEIVE_EMBED_PREVIEW',
165
+ type: "RECEIVE_EMBED_PREVIEW",
274
166
  url,
275
167
  preview
276
168
  };
277
169
  }
278
-
279
- /**
280
- * Action triggered to delete an entity record.
281
- *
282
- * @param {string} kind Kind of the deleted entity.
283
- * @param {string} name Name of the deleted entity.
284
- * @param {number|string} recordId Record ID of the deleted entity.
285
- * @param {?Object} query Special query parameters for the
286
- * DELETE API call.
287
- * @param {Object} [options] Delete options.
288
- * @param {Function} [options.__unstableFetch] Internal use only. Function to
289
- * call instead of `apiFetch()`.
290
- * Must return a promise.
291
- * @param {boolean} [options.throwOnError=false] If false, this action suppresses all
292
- * the exceptions. Defaults to false.
293
- */
294
- const deleteEntityRecord = (kind, name, recordId, query, {
295
- __unstableFetch = _apiFetch.default,
296
- throwOnError = false
297
- } = {}) => async ({
298
- dispatch,
299
- resolveSelect
300
- }) => {
301
- (0, _logEntityDeprecation.default)(kind, name, 'deleteEntityRecord');
170
+ const deleteEntityRecord = (kind, name, recordId, query, { __unstableFetch = import_api_fetch.default, throwOnError = false } = {}) => async ({ dispatch, resolveSelect }) => {
171
+ (0, import_log_entity_deprecation.default)(kind, name, "deleteEntityRecord");
302
172
  const configs = await resolveSelect.getEntitiesConfig(kind);
303
- const entityConfig = configs.find(config => config.kind === kind && config.name === name);
173
+ const entityConfig = configs.find(
174
+ (config) => config.kind === kind && config.name === name
175
+ );
304
176
  let error;
305
177
  let deletedRecord = false;
306
178
  if (!entityConfig) {
307
179
  return;
308
180
  }
309
- const lock = await dispatch.__unstableAcquireStoreLock(_name.STORE_NAME, ['entities', 'records', kind, name, recordId], {
310
- exclusive: true
311
- });
181
+ const lock = await dispatch.__unstableAcquireStoreLock(
182
+ import_name.STORE_NAME,
183
+ ["entities", "records", kind, name, recordId],
184
+ { exclusive: true }
185
+ );
312
186
  try {
313
187
  dispatch({
314
- type: 'DELETE_ENTITY_RECORD_START',
188
+ type: "DELETE_ENTITY_RECORD_START",
315
189
  kind,
316
190
  name,
317
191
  recordId
318
192
  });
319
193
  let hasError = false;
194
+ let { baseURL } = entityConfig;
195
+ if (kind === "postType" && name === "wp_template" && recordId && typeof recordId === "string" && !/^\d+$/.test(recordId)) {
196
+ baseURL = baseURL.slice(0, baseURL.lastIndexOf("/")) + "/templates";
197
+ }
320
198
  try {
321
- let path = `${entityConfig.baseURL}/${recordId}`;
199
+ let path = `${baseURL}/${recordId}`;
322
200
  if (query) {
323
- path = (0, _url.addQueryArgs)(path, query);
201
+ path = (0, import_url.addQueryArgs)(path, query);
324
202
  }
325
203
  deletedRecord = await __unstableFetch({
326
204
  path,
327
- method: 'DELETE'
205
+ method: "DELETE"
328
206
  });
329
- await dispatch((0, _queriedData.removeItems)(kind, name, recordId, true));
207
+ await dispatch((0, import_queried_data.removeItems)(kind, name, recordId, true));
330
208
  } catch (_error) {
331
209
  hasError = true;
332
210
  error = _error;
333
211
  }
334
212
  dispatch({
335
- type: 'DELETE_ENTITY_RECORD_FINISH',
213
+ type: "DELETE_ENTITY_RECORD_FINISH",
336
214
  kind,
337
215
  name,
338
216
  recordId,
@@ -346,35 +224,21 @@ const deleteEntityRecord = (kind, name, recordId, query, {
346
224
  dispatch.__unstableReleaseStoreLock(lock);
347
225
  }
348
226
  };
349
-
350
- /**
351
- * Returns an action object that triggers an
352
- * edit to an entity record.
353
- *
354
- * @param {string} kind Kind of the edited entity record.
355
- * @param {string} name Name of the edited entity record.
356
- * @param {number|string} recordId Record ID of the edited entity record.
357
- * @param {Object} edits The edits.
358
- * @param {Object} options Options for the edit.
359
- * @param {boolean} [options.undoIgnore] Whether to ignore the edit in undo history or not.
360
- *
361
- * @return {Object} Action object.
362
- */
363
- exports.deleteEntityRecord = deleteEntityRecord;
364
- const editEntityRecord = (kind, name, recordId, edits, options = {}) => ({
365
- select,
366
- dispatch
367
- }) => {
368
- (0, _logEntityDeprecation.default)(kind, name, 'editEntityRecord');
227
+ const editEntityRecord = (kind, name, recordId, edits, options = {}) => ({ select, dispatch }) => {
228
+ (0, import_log_entity_deprecation.default)(kind, name, "editEntityRecord");
369
229
  const entityConfig = select.getEntityConfig(kind, name);
370
230
  if (!entityConfig) {
371
- throw new Error(`The entity being edited (${kind}, ${name}) does not have a loaded config.`);
231
+ throw new Error(
232
+ `The entity being edited (${kind}, ${name}) does not have a loaded config.`
233
+ );
372
234
  }
373
- const {
374
- mergedEdits = {}
375
- } = entityConfig;
235
+ const { mergedEdits = {} } = entityConfig;
376
236
  const record = select.getRawEntityRecord(kind, name, recordId);
377
- const editedRecord = select.getEditedEntityRecord(kind, name, recordId);
237
+ const editedRecord = select.getEditedEntityRecord(
238
+ kind,
239
+ name,
240
+ recordId
241
+ );
378
242
  const edit = {
379
243
  kind,
380
244
  name,
@@ -384,168 +248,108 @@ const editEntityRecord = (kind, name, recordId, edits, options = {}) => ({
384
248
  edits: Object.keys(edits).reduce((acc, key) => {
385
249
  const recordValue = record[key];
386
250
  const editedRecordValue = editedRecord[key];
387
- const value = mergedEdits[key] ? {
388
- ...editedRecordValue,
389
- ...edits[key]
390
- } : edits[key];
391
- acc[key] = (0, _es.default)(recordValue, value) ? undefined : value;
251
+ const value = mergedEdits[key] ? { ...editedRecordValue, ...edits[key] } : edits[key];
252
+ acc[key] = (0, import_es6.default)(recordValue, value) ? void 0 : value;
392
253
  return acc;
393
254
  }, {})
394
255
  };
395
256
  if (window.__experimentalEnableSync && entityConfig.syncConfig) {
396
257
  if (globalThis.IS_GUTENBERG_PLUGIN) {
397
- const objectId = entityConfig.getSyncObjectId(recordId);
398
- (0, _sync.getSyncProvider)().update(entityConfig.syncObjectType + '--edit', objectId, edit.edits);
399
- }
400
- } else {
401
- if (!options.undoIgnore) {
402
- select.getUndoManager().addRecord([{
403
- id: {
404
- kind,
405
- name,
406
- recordId
407
- },
408
- changes: Object.keys(edits).reduce((acc, key) => {
409
- acc[key] = {
410
- from: editedRecord[key],
411
- to: edits[key]
412
- };
413
- return acc;
414
- }, {})
415
- }], options.isCached);
258
+ const objectType = `${kind}/${name}`;
259
+ const objectId = recordId;
260
+ import_sync.syncManager.update(
261
+ objectType,
262
+ objectId,
263
+ edit.edits,
264
+ import_sync.LOCAL_EDITOR_ORIGIN
265
+ );
416
266
  }
417
- dispatch({
418
- type: 'EDIT_ENTITY_RECORD',
419
- ...edit
420
- });
421
267
  }
268
+ if (!options.undoIgnore) {
269
+ select.getUndoManager().addRecord(
270
+ [
271
+ {
272
+ id: { kind, name, recordId },
273
+ changes: Object.keys(edits).reduce((acc, key) => {
274
+ acc[key] = {
275
+ from: editedRecord[key],
276
+ to: edits[key]
277
+ };
278
+ return acc;
279
+ }, {})
280
+ }
281
+ ],
282
+ options.isCached
283
+ );
284
+ }
285
+ dispatch({
286
+ type: "EDIT_ENTITY_RECORD",
287
+ ...edit
288
+ });
422
289
  };
423
-
424
- /**
425
- * Action triggered to undo the last edit to
426
- * an entity record, if any.
427
- */
428
- exports.editEntityRecord = editEntityRecord;
429
- const undo = () => ({
430
- select,
431
- dispatch
432
- }) => {
290
+ const undo = () => ({ select, dispatch }) => {
433
291
  const undoRecord = select.getUndoManager().undo();
434
292
  if (!undoRecord) {
435
293
  return;
436
294
  }
437
295
  dispatch({
438
- type: 'UNDO',
296
+ type: "UNDO",
439
297
  record: undoRecord
440
298
  });
441
299
  };
442
-
443
- /**
444
- * Action triggered to redo the last undone
445
- * edit to an entity record, if any.
446
- */
447
- exports.undo = undo;
448
- const redo = () => ({
449
- select,
450
- dispatch
451
- }) => {
300
+ const redo = () => ({ select, dispatch }) => {
452
301
  const redoRecord = select.getUndoManager().redo();
453
302
  if (!redoRecord) {
454
303
  return;
455
304
  }
456
305
  dispatch({
457
- type: 'REDO',
306
+ type: "REDO",
458
307
  record: redoRecord
459
308
  });
460
309
  };
461
-
462
- /**
463
- * Forces the creation of a new undo level.
464
- *
465
- * @return {Object} Action object.
466
- */
467
- exports.redo = redo;
468
- const __unstableCreateUndoLevel = () => ({
469
- select
470
- }) => {
310
+ const __unstableCreateUndoLevel = () => ({ select }) => {
471
311
  select.getUndoManager().addRecord();
472
312
  };
473
-
474
- /**
475
- * Action triggered to save an entity record.
476
- *
477
- * @param {string} kind Kind of the received entity.
478
- * @param {string} name Name of the received entity.
479
- * @param {Object} record Record to be saved.
480
- * @param {Object} options Saving options.
481
- * @param {boolean} [options.isAutosave=false] Whether this is an autosave.
482
- * @param {Function} [options.__unstableFetch] Internal use only. Function to
483
- * call instead of `apiFetch()`.
484
- * Must return a promise.
485
- * @param {boolean} [options.throwOnError=false] If false, this action suppresses all
486
- * the exceptions. Defaults to false.
487
- */
488
- exports.__unstableCreateUndoLevel = __unstableCreateUndoLevel;
489
313
  const saveEntityRecord = (kind, name, record, {
490
314
  isAutosave = false,
491
- __unstableFetch = _apiFetch.default,
315
+ __unstableFetch = import_api_fetch.default,
492
316
  throwOnError = false
493
- } = {}) => async ({
494
- select,
495
- resolveSelect,
496
- dispatch
497
- }) => {
498
- (0, _logEntityDeprecation.default)(kind, name, 'saveEntityRecord');
317
+ } = {}) => async ({ select, resolveSelect, dispatch }) => {
318
+ (0, import_log_entity_deprecation.default)(kind, name, "saveEntityRecord");
499
319
  const configs = await resolveSelect.getEntitiesConfig(kind);
500
- const entityConfig = configs.find(config => config.kind === kind && config.name === name);
320
+ const entityConfig = configs.find(
321
+ (config) => config.kind === kind && config.name === name
322
+ );
501
323
  if (!entityConfig) {
502
324
  return;
503
325
  }
504
- const entityIdKey = entityConfig.key || _entities.DEFAULT_ENTITY_KEY;
326
+ const entityIdKey = entityConfig.key || import_entities.DEFAULT_ENTITY_KEY;
505
327
  const recordId = record[entityIdKey];
506
-
507
- // When called with a theme template ID, trigger the compatibility
508
- // logic.
509
- if (kind === 'postType' && name === 'wp_template' && typeof recordId === 'string' && !/^\d+$/.test(recordId)) {
510
- // Get the theme template.
511
- const template = await select.getEntityRecord('postType', 'wp_registered_template', recordId);
512
- // Duplicate the theme template and make the edit.
513
- const newTemplate = await dispatch.saveEntityRecord('postType', 'wp_template', {
514
- ...template,
515
- ...record,
516
- id: undefined,
517
- type: 'wp_template',
518
- status: 'publish'
519
- });
520
- // Make the new template active.
521
- const activeTemplates = await select.getEntityRecord('root', 'site');
522
- await dispatch.saveEntityRecord('root', 'site', {
523
- active_templates: {
524
- ...activeTemplates.active_templates,
525
- [newTemplate.slug]: newTemplate.id
526
- }
527
- });
528
- return newTemplate;
529
- }
530
- const lock = await dispatch.__unstableAcquireStoreLock(_name.STORE_NAME, ['entities', 'records', kind, name, recordId || (0, _uuid.v4)()], {
531
- exclusive: true
532
- });
328
+ const lock = await dispatch.__unstableAcquireStoreLock(
329
+ import_name.STORE_NAME,
330
+ ["entities", "records", kind, name, recordId || (0, import_uuid.v4)()],
331
+ { exclusive: true }
332
+ );
533
333
  try {
534
- // Evaluate optimized edits.
535
- // (Function edits that should be evaluated on save to avoid expensive computations on every edit.)
536
334
  for (const [key, value] of Object.entries(record)) {
537
- if (typeof value === 'function') {
538
- const evaluatedValue = value(select.getEditedEntityRecord(kind, name, recordId));
539
- dispatch.editEntityRecord(kind, name, recordId, {
540
- [key]: evaluatedValue
541
- }, {
542
- undoIgnore: true
543
- });
335
+ if (typeof value === "function") {
336
+ const evaluatedValue = value(
337
+ select.getEditedEntityRecord(kind, name, recordId)
338
+ );
339
+ dispatch.editEntityRecord(
340
+ kind,
341
+ name,
342
+ recordId,
343
+ {
344
+ [key]: evaluatedValue
345
+ },
346
+ { undoIgnore: true }
347
+ );
544
348
  record[key] = evaluatedValue;
545
349
  }
546
350
  }
547
351
  dispatch({
548
- type: 'SAVE_ENTITY_RECORD_START',
352
+ type: "SAVE_ENTITY_RECORD_START",
549
353
  kind,
550
354
  name,
551
355
  recordId,
@@ -554,97 +358,123 @@ const saveEntityRecord = (kind, name, record, {
554
358
  let updatedRecord;
555
359
  let error;
556
360
  let hasError = false;
361
+ let { baseURL } = entityConfig;
362
+ if (kind === "postType" && name === "wp_template" && recordId && typeof recordId === "string" && !/^\d+$/.test(recordId)) {
363
+ baseURL = baseURL.slice(0, baseURL.lastIndexOf("/")) + "/templates";
364
+ }
557
365
  try {
558
- const path = `${entityConfig.baseURL}${recordId ? '/' + recordId : ''}`;
559
- const persistedRecord = select.getRawEntityRecord(kind, name, recordId);
366
+ const path = `${baseURL}${recordId ? "/" + recordId : ""}`;
367
+ const persistedRecord = select.getRawEntityRecord(
368
+ kind,
369
+ name,
370
+ recordId
371
+ );
560
372
  if (isAutosave) {
561
- // Most of this autosave logic is very specific to posts.
562
- // This is fine for now as it is the only supported autosave,
563
- // but ideally this should all be handled in the back end,
564
- // so the client just sends and receives objects.
565
373
  const currentUser = select.getCurrentUser();
566
- const currentUserId = currentUser ? currentUser.id : undefined;
567
- const autosavePost = await resolveSelect.getAutosave(persistedRecord.type, persistedRecord.id, currentUserId);
568
- // Autosaves need all expected fields to be present.
569
- // So we fallback to the previous autosave and then
570
- // to the actual persisted entity if the edits don't
571
- // have a value.
374
+ const currentUserId = currentUser ? currentUser.id : void 0;
375
+ const autosavePost = await resolveSelect.getAutosave(
376
+ persistedRecord.type,
377
+ persistedRecord.id,
378
+ currentUserId
379
+ );
572
380
  let data = {
573
381
  ...persistedRecord,
574
382
  ...autosavePost,
575
383
  ...record
576
384
  };
577
- data = Object.keys(data).reduce((acc, key) => {
578
- if (['title', 'excerpt', 'content', 'meta'].includes(key)) {
579
- acc[key] = data[key];
385
+ data = Object.keys(data).reduce(
386
+ (acc, key) => {
387
+ if ([
388
+ "title",
389
+ "excerpt",
390
+ "content",
391
+ "meta"
392
+ ].includes(key)) {
393
+ acc[key] = data[key];
394
+ }
395
+ return acc;
396
+ },
397
+ {
398
+ // Do not update the `status` if we have edited it when auto saving.
399
+ // It's very important to let the user explicitly save this change,
400
+ // because it can lead to unexpected results. An example would be to
401
+ // have a draft post and change the status to publish.
402
+ status: data.status === "auto-draft" ? "draft" : void 0
580
403
  }
581
- return acc;
582
- }, {
583
- // Do not update the `status` if we have edited it when auto saving.
584
- // It's very important to let the user explicitly save this change,
585
- // because it can lead to unexpected results. An example would be to
586
- // have a draft post and change the status to publish.
587
- status: data.status === 'auto-draft' ? 'draft' : undefined
588
- });
404
+ );
589
405
  updatedRecord = await __unstableFetch({
590
406
  path: `${path}/autosaves`,
591
- method: 'POST',
407
+ method: "POST",
592
408
  data
593
409
  });
594
-
595
- // An autosave may be processed by the server as a regular save
596
- // when its update is requested by the author and the post had
597
- // draft or auto-draft status.
598
410
  if (persistedRecord.id === updatedRecord.id) {
599
411
  let newRecord = {
600
412
  ...persistedRecord,
601
413
  ...data,
602
414
  ...updatedRecord
603
415
  };
604
- newRecord = Object.keys(newRecord).reduce((acc, key) => {
605
- // These properties are persisted in autosaves.
606
- if (['title', 'excerpt', 'content'].includes(key)) {
607
- acc[key] = newRecord[key];
608
- } else if (key === 'status') {
609
- // Status is only persisted in autosaves when going from
610
- // "auto-draft" to "draft".
611
- acc[key] = persistedRecord.status === 'auto-draft' && newRecord.status === 'draft' ? newRecord.status : persistedRecord.status;
612
- } else {
613
- // These properties are not persisted in autosaves.
614
- acc[key] = persistedRecord[key];
615
- }
616
- return acc;
617
- }, {});
618
- dispatch.receiveEntityRecords(kind, name, newRecord, undefined, true);
416
+ newRecord = Object.keys(newRecord).reduce(
417
+ (acc, key) => {
418
+ if (["title", "excerpt", "content"].includes(
419
+ key
420
+ )) {
421
+ acc[key] = newRecord[key];
422
+ } else if (key === "status") {
423
+ acc[key] = persistedRecord.status === "auto-draft" && newRecord.status === "draft" ? newRecord.status : persistedRecord.status;
424
+ } else {
425
+ acc[key] = persistedRecord[key];
426
+ }
427
+ return acc;
428
+ },
429
+ {}
430
+ );
431
+ dispatch.receiveEntityRecords(
432
+ kind,
433
+ name,
434
+ newRecord,
435
+ void 0,
436
+ true
437
+ );
619
438
  } else {
620
- dispatch.receiveAutosaves(persistedRecord.id, updatedRecord);
439
+ dispatch.receiveAutosaves(
440
+ persistedRecord.id,
441
+ updatedRecord
442
+ );
621
443
  }
622
444
  } else {
623
445
  let edits = record;
624
446
  if (entityConfig.__unstablePrePersist) {
625
447
  edits = {
626
448
  ...edits,
627
- ...entityConfig.__unstablePrePersist(persistedRecord, edits)
449
+ ...entityConfig.__unstablePrePersist(
450
+ persistedRecord,
451
+ edits
452
+ )
628
453
  };
629
454
  }
630
- // Unless there is no persisted record, set the status to
631
- // publish.
632
- if (name === 'wp_template' && persistedRecord) {
633
- edits.status = 'publish';
455
+ if (name === "wp_template" && persistedRecord) {
456
+ edits.status = "publish";
634
457
  }
635
458
  updatedRecord = await __unstableFetch({
636
459
  path,
637
- method: recordId ? 'PUT' : 'POST',
460
+ method: recordId ? "PUT" : "POST",
638
461
  data: edits
639
462
  });
640
- dispatch.receiveEntityRecords(kind, name, updatedRecord, undefined, true, edits);
463
+ dispatch.receiveEntityRecords(
464
+ kind,
465
+ name,
466
+ updatedRecord,
467
+ void 0,
468
+ true,
469
+ edits
470
+ );
641
471
  }
642
472
  } catch (_error) {
643
473
  hasError = true;
644
474
  error = _error;
645
475
  }
646
476
  dispatch({
647
- type: 'SAVE_ENTITY_RECORD_FINISH',
477
+ type: "SAVE_ENTITY_RECORD_FINISH",
648
478
  kind,
649
479
  name,
650
480
  recordId,
@@ -659,260 +489,144 @@ const saveEntityRecord = (kind, name, record, {
659
489
  dispatch.__unstableReleaseStoreLock(lock);
660
490
  }
661
491
  };
662
-
663
- /**
664
- * Runs multiple core-data actions at the same time using one API request.
665
- *
666
- * Example:
667
- *
668
- * ```
669
- * const [ savedRecord, updatedRecord, deletedRecord ] =
670
- * await dispatch( 'core' ).__experimentalBatch( [
671
- * ( { saveEntityRecord } ) => saveEntityRecord( 'root', 'widget', widget ),
672
- * ( { saveEditedEntityRecord } ) => saveEntityRecord( 'root', 'widget', 123 ),
673
- * ( { deleteEntityRecord } ) => deleteEntityRecord( 'root', 'widget', 123, null ),
674
- * ] );
675
- * ```
676
- *
677
- * @param {Array} requests Array of functions which are invoked simultaneously.
678
- * Each function is passed an object containing
679
- * `saveEntityRecord`, `saveEditedEntityRecord`, and
680
- * `deleteEntityRecord`.
681
- *
682
- * @return {(thunkArgs: Object) => Promise} A promise that resolves to an array containing the return
683
- * values of each function given in `requests`.
684
- */
685
- exports.saveEntityRecord = saveEntityRecord;
686
- const __experimentalBatch = requests => async ({
687
- dispatch
688
- }) => {
689
- const batch = (0, _batch.createBatch)();
492
+ const __experimentalBatch = (requests) => async ({ dispatch }) => {
493
+ const batch = (0, import_batch.createBatch)();
690
494
  const api = {
691
495
  saveEntityRecord(kind, name, record, options) {
692
- return batch.add(add => dispatch.saveEntityRecord(kind, name, record, {
693
- ...options,
694
- __unstableFetch: add
695
- }));
496
+ return batch.add(
497
+ (add) => dispatch.saveEntityRecord(kind, name, record, {
498
+ ...options,
499
+ __unstableFetch: add
500
+ })
501
+ );
696
502
  },
697
503
  saveEditedEntityRecord(kind, name, recordId, options) {
698
- return batch.add(add => dispatch.saveEditedEntityRecord(kind, name, recordId, {
699
- ...options,
700
- __unstableFetch: add
701
- }));
504
+ return batch.add(
505
+ (add) => dispatch.saveEditedEntityRecord(kind, name, recordId, {
506
+ ...options,
507
+ __unstableFetch: add
508
+ })
509
+ );
702
510
  },
703
511
  deleteEntityRecord(kind, name, recordId, query, options) {
704
- return batch.add(add => dispatch.deleteEntityRecord(kind, name, recordId, query, {
705
- ...options,
706
- __unstableFetch: add
707
- }));
512
+ return batch.add(
513
+ (add) => dispatch.deleteEntityRecord(kind, name, recordId, query, {
514
+ ...options,
515
+ __unstableFetch: add
516
+ })
517
+ );
708
518
  }
709
519
  };
710
- const resultPromises = requests.map(request => request(api));
711
- const [, ...results] = await Promise.all([batch.run(), ...resultPromises]);
520
+ const resultPromises = requests.map((request) => request(api));
521
+ const [, ...results] = await Promise.all([
522
+ batch.run(),
523
+ ...resultPromises
524
+ ]);
712
525
  return results;
713
526
  };
714
-
715
- /**
716
- * Action triggered to save an entity record's edits.
717
- *
718
- * @param {string} kind Kind of the entity.
719
- * @param {string} name Name of the entity.
720
- * @param {Object} recordId ID of the record.
721
- * @param {Object=} options Saving options.
722
- */
723
- exports.__experimentalBatch = __experimentalBatch;
724
- const saveEditedEntityRecord = (kind, name, recordId, options) => async ({
725
- select,
726
- dispatch,
727
- resolveSelect
728
- }) => {
729
- (0, _logEntityDeprecation.default)(kind, name, 'saveEditedEntityRecord');
527
+ const saveEditedEntityRecord = (kind, name, recordId, options) => async ({ select, dispatch, resolveSelect }) => {
528
+ (0, import_log_entity_deprecation.default)(kind, name, "saveEditedEntityRecord");
730
529
  if (!select.hasEditsForEntityRecord(kind, name, recordId)) {
731
530
  return;
732
531
  }
733
532
  const configs = await resolveSelect.getEntitiesConfig(kind);
734
- const entityConfig = configs.find(config => config.kind === kind && config.name === name);
533
+ const entityConfig = configs.find(
534
+ (config) => config.kind === kind && config.name === name
535
+ );
735
536
  if (!entityConfig) {
736
537
  return;
737
538
  }
738
- const entityIdKey = entityConfig.key || _entities.DEFAULT_ENTITY_KEY;
739
- const edits = select.getEntityRecordNonTransientEdits(kind, name, recordId);
740
- const record = {
741
- [entityIdKey]: recordId,
742
- ...edits
743
- };
539
+ const entityIdKey = entityConfig.key || import_entities.DEFAULT_ENTITY_KEY;
540
+ const edits = select.getEntityRecordNonTransientEdits(
541
+ kind,
542
+ name,
543
+ recordId
544
+ );
545
+ const record = { [entityIdKey]: recordId, ...edits };
744
546
  return await dispatch.saveEntityRecord(kind, name, record, options);
745
547
  };
746
-
747
- /**
748
- * Action triggered to save only specified properties for the entity.
749
- *
750
- * @param {string} kind Kind of the entity.
751
- * @param {string} name Name of the entity.
752
- * @param {number|string} recordId ID of the record.
753
- * @param {Array} itemsToSave List of entity properties or property paths to save.
754
- * @param {Object} options Saving options.
755
- */
756
- exports.saveEditedEntityRecord = saveEditedEntityRecord;
757
- const __experimentalSaveSpecifiedEntityEdits = (kind, name, recordId, itemsToSave, options) => async ({
758
- select,
759
- dispatch,
760
- resolveSelect
761
- }) => {
762
- (0, _logEntityDeprecation.default)(kind, name, '__experimentalSaveSpecifiedEntityEdits');
548
+ const __experimentalSaveSpecifiedEntityEdits = (kind, name, recordId, itemsToSave, options) => async ({ select, dispatch, resolveSelect }) => {
549
+ (0, import_log_entity_deprecation.default)(
550
+ kind,
551
+ name,
552
+ "__experimentalSaveSpecifiedEntityEdits"
553
+ );
763
554
  if (!select.hasEditsForEntityRecord(kind, name, recordId)) {
764
555
  return;
765
556
  }
766
- const edits = select.getEntityRecordNonTransientEdits(kind, name, recordId);
557
+ const edits = select.getEntityRecordNonTransientEdits(
558
+ kind,
559
+ name,
560
+ recordId
561
+ );
767
562
  const editsToSave = {};
768
563
  for (const item of itemsToSave) {
769
- (0, _utils.setNestedValue)(editsToSave, item, (0, _utils.getNestedValue)(edits, item));
564
+ (0, import_utils.setNestedValue)(editsToSave, item, (0, import_utils.getNestedValue)(edits, item));
770
565
  }
771
566
  const configs = await resolveSelect.getEntitiesConfig(kind);
772
- const entityConfig = configs.find(config => config.kind === kind && config.name === name);
773
- const entityIdKey = entityConfig?.key || _entities.DEFAULT_ENTITY_KEY;
774
-
775
- // If a record key is provided then update the existing record.
776
- // This necessitates providing `recordKey` to saveEntityRecord as part of the
777
- // `record` argument (here called `editsToSave`) to stop that action creating
778
- // a new record and instead cause it to update the existing record.
567
+ const entityConfig = configs.find(
568
+ (config) => config.kind === kind && config.name === name
569
+ );
570
+ const entityIdKey = entityConfig?.key || import_entities.DEFAULT_ENTITY_KEY;
779
571
  if (recordId) {
780
572
  editsToSave[entityIdKey] = recordId;
781
573
  }
782
- return await dispatch.saveEntityRecord(kind, name, editsToSave, options);
574
+ return await dispatch.saveEntityRecord(
575
+ kind,
576
+ name,
577
+ editsToSave,
578
+ options
579
+ );
783
580
  };
784
-
785
- /**
786
- * Returns an action object used in signalling that Upload permissions have been received.
787
- *
788
- * @deprecated since WP 5.9, use receiveUserPermission instead.
789
- *
790
- * @param {boolean} hasUploadPermissions Does the user have permission to upload files?
791
- *
792
- * @return {Object} Action object.
793
- */
794
- exports.__experimentalSaveSpecifiedEntityEdits = __experimentalSaveSpecifiedEntityEdits;
795
581
  function receiveUploadPermissions(hasUploadPermissions) {
796
- (0, _deprecated.default)("wp.data.dispatch( 'core' ).receiveUploadPermissions", {
797
- since: '5.9',
798
- alternative: 'receiveUserPermission'
582
+ (0, import_deprecated.default)("wp.data.dispatch( 'core' ).receiveUploadPermissions", {
583
+ since: "5.9",
584
+ alternative: "receiveUserPermission"
799
585
  });
800
- return receiveUserPermission('create/media', hasUploadPermissions);
586
+ return receiveUserPermission("create/media", hasUploadPermissions);
801
587
  }
802
-
803
- /**
804
- * Returns an action object used in signalling that the current user has
805
- * permission to perform an action on a REST resource.
806
- * Ignored from documentation as it's internal to the data store.
807
- *
808
- * @ignore
809
- *
810
- * @param {string} key A key that represents the action and REST resource.
811
- * @param {boolean} isAllowed Whether or not the user can perform the action.
812
- *
813
- * @return {Object} Action object.
814
- */
815
588
  function receiveUserPermission(key, isAllowed) {
816
589
  return {
817
- type: 'RECEIVE_USER_PERMISSION',
590
+ type: "RECEIVE_USER_PERMISSION",
818
591
  key,
819
592
  isAllowed
820
593
  };
821
594
  }
822
-
823
- /**
824
- * Returns an action object used in signalling that the current user has
825
- * permission to perform an action on a REST resource. Ignored from
826
- * documentation as it's internal to the data store.
827
- *
828
- * @ignore
829
- *
830
- * @param {Object<string, boolean>} permissions An object where keys represent
831
- * actions and REST resources, and
832
- * values indicate whether the user
833
- * is allowed to perform the
834
- * action.
835
- *
836
- * @return {Object} Action object.
837
- */
838
595
  function receiveUserPermissions(permissions) {
839
596
  return {
840
- type: 'RECEIVE_USER_PERMISSIONS',
597
+ type: "RECEIVE_USER_PERMISSIONS",
841
598
  permissions
842
599
  };
843
600
  }
844
-
845
- /**
846
- * Returns an action object used in signalling that the autosaves for a
847
- * post have been received.
848
- * Ignored from documentation as it's internal to the data store.
849
- *
850
- * @ignore
851
- *
852
- * @param {number} postId The id of the post that is parent to the autosave.
853
- * @param {Array|Object} autosaves An array of autosaves or singular autosave object.
854
- *
855
- * @return {Object} Action object.
856
- */
857
601
  function receiveAutosaves(postId, autosaves) {
858
602
  return {
859
- type: 'RECEIVE_AUTOSAVES',
603
+ type: "RECEIVE_AUTOSAVES",
860
604
  postId,
861
605
  autosaves: Array.isArray(autosaves) ? autosaves : [autosaves]
862
606
  };
863
607
  }
864
-
865
- /**
866
- * Returns an action object signalling that the fallback Navigation
867
- * Menu id has been received.
868
- *
869
- * @param {integer} fallbackId the id of the fallback Navigation Menu
870
- * @return {Object} Action object.
871
- */
872
608
  function receiveNavigationFallbackId(fallbackId) {
873
609
  return {
874
- type: 'RECEIVE_NAVIGATION_FALLBACK_ID',
610
+ type: "RECEIVE_NAVIGATION_FALLBACK_ID",
875
611
  fallbackId
876
612
  };
877
613
  }
878
-
879
- /**
880
- * Returns an action object used to set the template for a given query.
881
- *
882
- * @param {Object} query The lookup query.
883
- * @param {string} templateId The resolved template id.
884
- *
885
- * @return {Object} Action object.
886
- */
887
614
  function receiveDefaultTemplateId(query, templateId) {
888
615
  return {
889
- type: 'RECEIVE_DEFAULT_TEMPLATE',
616
+ type: "RECEIVE_DEFAULT_TEMPLATE",
890
617
  query,
891
618
  templateId
892
619
  };
893
620
  }
894
-
895
- /**
896
- * Action triggered to receive revision items.
897
- *
898
- * @param {string} kind Kind of the received entity record revisions.
899
- * @param {string} name Name of the received entity record revisions.
900
- * @param {number|string} recordKey The key of the entity record whose revisions you want to fetch.
901
- * @param {Array|Object} records Revisions received.
902
- * @param {?Object} query Query Object.
903
- * @param {?boolean} invalidateCache Should invalidate query caches.
904
- * @param {?Object} meta Meta information about pagination.
905
- */
906
- const receiveRevisions = (kind, name, recordKey, records, query, invalidateCache = false, meta) => async ({
907
- dispatch,
908
- resolveSelect
909
- }) => {
910
- (0, _logEntityDeprecation.default)(kind, name, 'receiveRevisions');
621
+ const receiveRevisions = (kind, name, recordKey, records, query, invalidateCache = false, meta) => async ({ dispatch, resolveSelect }) => {
622
+ (0, import_log_entity_deprecation.default)(kind, name, "receiveRevisions");
911
623
  const configs = await resolveSelect.getEntitiesConfig(kind);
912
- const entityConfig = configs.find(config => config.kind === kind && config.name === name);
913
- const key = entityConfig && entityConfig?.revisionKey ? entityConfig.revisionKey : _entities.DEFAULT_ENTITY_KEY;
624
+ const entityConfig = configs.find(
625
+ (config) => config.kind === kind && config.name === name
626
+ );
627
+ const key = entityConfig && entityConfig?.revisionKey ? entityConfig.revisionKey : import_entities.DEFAULT_ENTITY_KEY;
914
628
  dispatch({
915
- type: 'RECEIVE_ITEM_REVISIONS',
629
+ type: "RECEIVE_ITEM_REVISIONS",
916
630
  key,
917
631
  items: Array.isArray(records) ? records : [records],
918
632
  recordKey,
@@ -923,5 +637,34 @@ const receiveRevisions = (kind, name, recordKey, records, query, invalidateCache
923
637
  invalidateCache
924
638
  });
925
639
  };
926
- exports.receiveRevisions = receiveRevisions;
927
- //# sourceMappingURL=actions.js.map
640
+ // Annotate the CommonJS export names for ESM import in node:
641
+ 0 && (module.exports = {
642
+ __experimentalBatch,
643
+ __experimentalReceiveCurrentGlobalStylesId,
644
+ __experimentalReceiveThemeBaseGlobalStyles,
645
+ __experimentalReceiveThemeGlobalStyleVariations,
646
+ __experimentalSaveSpecifiedEntityEdits,
647
+ __unstableCreateUndoLevel,
648
+ addEntities,
649
+ deleteEntityRecord,
650
+ editEntityRecord,
651
+ receiveAutosaves,
652
+ receiveCurrentTheme,
653
+ receiveCurrentUser,
654
+ receiveDefaultTemplateId,
655
+ receiveEmbedPreview,
656
+ receiveEntityRecords,
657
+ receiveNavigationFallbackId,
658
+ receiveRevisions,
659
+ receiveThemeGlobalStyleRevisions,
660
+ receiveThemeSupports,
661
+ receiveUploadPermissions,
662
+ receiveUserPermission,
663
+ receiveUserPermissions,
664
+ receiveUserQuery,
665
+ redo,
666
+ saveEditedEntityRecord,
667
+ saveEntityRecord,
668
+ undo
669
+ });
670
+ //# sourceMappingURL=actions.js.map