@wordpress/core-data 6.11.0 → 6.12.1

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 (131) hide show
  1. package/CHANGELOG.md +2 -0
  2. package/README.md +5 -1
  3. package/build/actions.js +252 -276
  4. package/build/actions.js.map +1 -1
  5. package/build/batch/create-batch.js +8 -16
  6. package/build/batch/create-batch.js.map +1 -1
  7. package/build/batch/default-processor.js +1 -1
  8. package/build/batch/default-processor.js.map +1 -1
  9. package/build/entities.js +16 -25
  10. package/build/entities.js.map +1 -1
  11. package/build/entity-provider.js +74 -23
  12. package/build/entity-provider.js.map +1 -1
  13. package/build/fetch/__experimental-fetch-link-suggestions.js +2 -6
  14. package/build/fetch/__experimental-fetch-link-suggestions.js.map +1 -1
  15. package/build/fetch/__experimental-fetch-url-data.js +1 -2
  16. package/build/fetch/__experimental-fetch-url-data.js.map +1 -1
  17. package/build/hooks/use-entity-record.js +11 -13
  18. package/build/hooks/use-entity-record.js.map +1 -1
  19. package/build/hooks/use-entity-records.js +4 -6
  20. package/build/hooks/use-entity-records.js.map +1 -1
  21. package/build/hooks/use-query-select.js +1 -6
  22. package/build/hooks/use-query-select.js.map +1 -1
  23. package/build/index.js +1 -7
  24. package/build/index.js.map +1 -1
  25. package/build/locks/actions.js +3 -4
  26. package/build/locks/actions.js.map +1 -1
  27. package/build/locks/reducer.js +1 -4
  28. package/build/locks/reducer.js.map +1 -1
  29. package/build/locks/selectors.js +3 -4
  30. package/build/locks/selectors.js.map +1 -1
  31. package/build/locks/utils.js +3 -5
  32. package/build/locks/utils.js.map +1 -1
  33. package/build/private-apis.js +19 -0
  34. package/build/private-apis.js.map +1 -0
  35. package/build/private-selectors.js +37 -0
  36. package/build/private-selectors.js.map +1 -0
  37. package/build/queried-data/actions.js +2 -5
  38. package/build/queried-data/actions.js.map +1 -1
  39. package/build/queried-data/reducer.js +17 -47
  40. package/build/queried-data/reducer.js.map +1 -1
  41. package/build/queried-data/selectors.js +4 -11
  42. package/build/queried-data/selectors.js.map +1 -1
  43. package/build/reducer.js +167 -194
  44. package/build/reducer.js.map +1 -1
  45. package/build/resolvers.js +175 -220
  46. package/build/resolvers.js.map +1 -1
  47. package/build/selectors.js +53 -61
  48. package/build/selectors.js.map +1 -1
  49. package/build/utils/forward-resolver.js +4 -11
  50. package/build/utils/forward-resolver.js.map +1 -1
  51. package/build/utils/on-sub-key.js +1 -3
  52. package/build/utils/on-sub-key.js.map +1 -1
  53. package/build-module/actions.js +251 -276
  54. package/build-module/actions.js.map +1 -1
  55. package/build-module/batch/create-batch.js +8 -16
  56. package/build-module/batch/create-batch.js.map +1 -1
  57. package/build-module/batch/default-processor.js +1 -1
  58. package/build-module/batch/default-processor.js.map +1 -1
  59. package/build-module/entities.js +16 -25
  60. package/build-module/entities.js.map +1 -1
  61. package/build-module/entity-provider.js +71 -22
  62. package/build-module/entity-provider.js.map +1 -1
  63. package/build-module/fetch/__experimental-fetch-link-suggestions.js +2 -6
  64. package/build-module/fetch/__experimental-fetch-link-suggestions.js.map +1 -1
  65. package/build-module/fetch/__experimental-fetch-url-data.js +1 -2
  66. package/build-module/fetch/__experimental-fetch-url-data.js.map +1 -1
  67. package/build-module/hooks/use-entity-record.js +11 -13
  68. package/build-module/hooks/use-entity-record.js.map +1 -1
  69. package/build-module/hooks/use-entity-records.js +4 -6
  70. package/build-module/hooks/use-entity-records.js.map +1 -1
  71. package/build-module/hooks/use-query-select.js +1 -6
  72. package/build-module/hooks/use-query-select.js.map +1 -1
  73. package/build-module/index.js +1 -7
  74. package/build-module/index.js.map +1 -1
  75. package/build-module/locks/actions.js +3 -4
  76. package/build-module/locks/actions.js.map +1 -1
  77. package/build-module/locks/reducer.js +1 -4
  78. package/build-module/locks/reducer.js.map +1 -1
  79. package/build-module/locks/selectors.js +3 -4
  80. package/build-module/locks/selectors.js.map +1 -1
  81. package/build-module/locks/utils.js +3 -5
  82. package/build-module/locks/utils.js.map +1 -1
  83. package/build-module/private-apis.js +9 -0
  84. package/build-module/private-apis.js.map +1 -0
  85. package/build-module/private-selectors.js +28 -0
  86. package/build-module/private-selectors.js.map +1 -0
  87. package/build-module/queried-data/actions.js +2 -5
  88. package/build-module/queried-data/actions.js.map +1 -1
  89. package/build-module/queried-data/reducer.js +17 -47
  90. package/build-module/queried-data/reducer.js.map +1 -1
  91. package/build-module/queried-data/selectors.js +4 -11
  92. package/build-module/queried-data/selectors.js.map +1 -1
  93. package/build-module/reducer.js +168 -194
  94. package/build-module/reducer.js.map +1 -1
  95. package/build-module/resolvers.js +175 -220
  96. package/build-module/resolvers.js.map +1 -1
  97. package/build-module/selectors.js +55 -61
  98. package/build-module/selectors.js.map +1 -1
  99. package/build-module/utils/forward-resolver.js +4 -11
  100. package/build-module/utils/forward-resolver.js.map +1 -1
  101. package/build-module/utils/on-sub-key.js +1 -3
  102. package/build-module/utils/on-sub-key.js.map +1 -1
  103. package/build-types/actions.d.ts.map +1 -1
  104. package/build-types/entity-provider.d.ts.map +1 -1
  105. package/build-types/entity-types/wp-template.d.ts +4 -0
  106. package/build-types/entity-types/wp-template.d.ts.map +1 -1
  107. package/build-types/hooks/use-entity-record.d.ts.map +1 -1
  108. package/build-types/hooks/use-entity-records.d.ts +1 -1
  109. package/build-types/private-apis.d.ts +3 -0
  110. package/build-types/private-apis.d.ts.map +1 -0
  111. package/build-types/private-selectors.d.ts +25 -0
  112. package/build-types/private-selectors.d.ts.map +1 -0
  113. package/build-types/reducer.d.ts +6 -2
  114. package/build-types/reducer.d.ts.map +1 -1
  115. package/build-types/selectors.d.ts +16 -4
  116. package/build-types/selectors.d.ts.map +1 -1
  117. package/package.json +14 -12
  118. package/src/actions.js +9 -8
  119. package/src/entity-provider.js +72 -5
  120. package/src/entity-types/wp-template.ts +4 -0
  121. package/src/hooks/use-entity-record.ts +4 -2
  122. package/src/hooks/use-entity-records.ts +1 -1
  123. package/src/index.js +0 -1
  124. package/src/private-apis.js +10 -0
  125. package/src/private-selectors.ts +30 -0
  126. package/src/reducer.js +130 -104
  127. package/src/selectors.ts +33 -13
  128. package/src/test/reducer.js +89 -54
  129. package/src/test/selectors.js +8 -8
  130. package/tsconfig.json +2 -0
  131. package/tsconfig.tsbuildinfo +1 -1
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/core-data/src/resolvers.js"],"names":["camelCase","addQueryArgs","apiFetch","STORE_NAME","getOrLoadEntitiesConfig","DEFAULT_ENTITY_KEY","forwardResolver","getNormalizedCommaSeparable","getAuthors","query","dispatch","path","users","receiveUserQuery","getCurrentUser","currentUser","receiveCurrentUser","getEntityRecord","kind","name","key","select","configs","entityConfig","find","config","__experimentalNoFetch","lock","__unstableAcquireStoreLock","exclusive","undefined","_fields","Set","join","baseURL","baseURLParams","include","hasRecords","hasEntityRecords","record","receiveEntityRecords","__unstableReleaseStoreLock","getRawEntityRecord","getEditedEntityRecord","getEntityRecords","records","Object","values","map","split","forEach","field","hasOwnProperty","context","resolutionsArgs","filter","type","selectorName","args","shouldInvalidate","action","invalidateCache","getCurrentTheme","resolveSelect","activeThemes","status","receiveCurrentTheme","getThemeSupports","getEmbedPreview","url","embedProxyResponse","receiveEmbedPreview","error","canUser","requestedAction","resource","id","registry","hasStartedResolution","resourcePath","retrievedActions","includes","Error","relatedAction","isAlreadyResolving","response","method","parse","allowHeader","headers","get","allowedMethods","allow","permissions","methods","create","read","update","delete","actionName","methodName","entries","receiveUserPermission","canUserEditEntityRecord","recordId","__unstable_rest_base","getAutosaves","postType","postId","rest_base","restBase","rest_namespace","restNamespace","getPostType","autosaves","length","receiveAutosaves","getAutosave","__experimentalGetTemplateForLink","link","template","then","data","e","__experimentalGetCurrentGlobalStylesId","globalStylesURL","_links","href","globalStylesObject","__experimentalReceiveCurrentGlobalStylesId","__experimentalGetCurrentThemeBaseGlobalStyles","currentTheme","themeGlobalStyles","stylesheet","__experimentalReceiveThemeBaseGlobalStyles","__experimentalGetCurrentThemeGlobalStylesVariations","variations","__experimentalReceiveThemeGlobalStyleVariations","getCurrentThemeGlobalStylesRevisions","globalStylesId","revisionsURL","resetRevisions","revisions","revision","fromEntries","value","receiveThemeGlobalStyleRevisions","getBlockPatterns","restPatterns","patterns","pattern","getBlockPatternCategories","categories","getNavigationFallbackId","fallback","_embed","_embedded","self","receiveNavigationFallbackId","finishResolution"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,SAAT,QAA0B,aAA1B;AAEA;AACA;AACA;;AACA,SAASC,YAAT,QAA6B,gBAA7B;AACA,OAAOC,QAAP,MAAqB,sBAArB;AAEA;AACA;AACA;;AACA,SAASC,UAAT,QAA2B,QAA3B;AACA,SAASC,uBAAT,EAAkCC,kBAAlC,QAA4D,YAA5D;AACA,SAASC,eAAT,EAA0BC,2BAA1B,QAA6D,SAA7D;AAEA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,MAAMC,UAAU,GACpBC,KAAF,IACA,cAA0B;AAAA,MAAlB;AAAEC,IAAAA;AAAF,GAAkB;AACzB,QAAMC,IAAI,GAAGV,YAAY,CACxB,wCADwB,EAExBQ,KAFwB,CAAzB;AAIA,QAAMG,KAAK,GAAG,MAAMV,QAAQ,CAAE;AAAES,IAAAA;AAAF,GAAF,CAA5B;AACAD,EAAAA,QAAQ,CAACG,gBAAT,CAA2BF,IAA3B,EAAiCC,KAAjC;AACA,CATK;AAWP;AACA;AACA;;AACA,OAAO,MAAME,cAAc,GAC1B,MACA,eAA0B;AAAA,MAAlB;AAAEJ,IAAAA;AAAF,GAAkB;AACzB,QAAMK,WAAW,GAAG,MAAMb,QAAQ,CAAE;AAAES,IAAAA,IAAI,EAAE;AAAR,GAAF,CAAlC;AACAD,EAAAA,QAAQ,CAACM,kBAAT,CAA6BD,WAA7B;AACA,CALK;AAOP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,MAAME,eAAe,GAC3B,UAAEC,IAAF,EAAQC,IAAR;AAAA,MAAcC,GAAd,uEAAoB,EAApB;AAAA,MAAwBX,KAAxB;AAA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MACA,gBAA0B;AAAA,MAAlB;AAAE7I,IAAAA;AAAF,GAAkB;AACzB,QAAM8I,UAAU,GAAG,MAAMtJ,QAAQ,CAAE;AAClCS,IAAAA,IAAI,EAAE;AAD4B,GAAF,CAAjC;AAGAD,EAAAA,QAAQ,CAAE;AAAE8C,IAAAA,IAAI,EAAE,kCAAR;AAA4CgG,IAAAA;AAA5C,GAAF,CAAR;AACA,CAPK;AASP,OAAO,MAAMC,uBAAuB,GACnC,MACA,gBAA0B;AAAA;;AAAA,MAAlB;AAAE/I,IAAAA;AAAF,GAAkB;AACzB,QAAMgJ,QAAQ,GAAG,MAAMxJ,QAAQ,CAAE;AAChCS,IAAAA,IAAI,EAAEV,YAAY,CAAE,yCAAF,EAA6C;AAC9D0J,MAAAA,MAAM,EAAE;AADsD,KAA7C;AADc,GAAF,CAA/B;AAMA,QAAMpH,MAAM,GAAGmH,QAAH,aAAGA,QAAH,8CAAGA,QAAQ,CAAEE,SAAb,wDAAG,oBAAqBC,IAApC;AAEAnJ,EAAAA,QAAQ,CAACoJ,2BAAT,CAAsCJ,QAAtC,aAAsCA,QAAtC,uBAAsCA,QAAQ,CAAE9E,EAAhD;;AAEA,MAAKrC,MAAL,EAAc;AACb7B,IAAAA,QAAQ,CAAC8B,oBAAT,CACC,UADD,EAEC,eAFD,EAGCD,MAHD,EADa,CAOb;;AACA7B,IAAAA,QAAQ,CAACqJ,gBAAT,CAA2B,iBAA3B,EAA8C,CAC7C,UAD6C,EAE7C,eAF6C,EAG7CL,QAH6C,aAG7CA,QAH6C,uBAG7CA,QAAQ,CAAE9E,EAHmC,CAA9C;AAKA;AACD,CA3BK","sourcesContent":["/**\n * External dependencies\n */\nimport { camelCase } from 'change-case';\n\n/**\n * WordPress dependencies\n */\nimport { addQueryArgs } from '@wordpress/url';\nimport apiFetch from '@wordpress/api-fetch';\n\n/**\n * Internal dependencies\n */\nimport { STORE_NAME } from './name';\nimport { getOrLoadEntitiesConfig, DEFAULT_ENTITY_KEY } from './entities';\nimport { forwardResolver, getNormalizedCommaSeparable } from './utils';\n\n/**\n * Requests authors from the REST API.\n *\n * @param {Object|undefined} query Optional object of query parameters to\n * include with request.\n */\nexport const getAuthors =\n\t( query ) =>\n\tasync ( { dispatch } ) => {\n\t\tconst path = addQueryArgs(\n\t\t\t'/wp/v2/users/?who=authors&per_page=100',\n\t\t\tquery\n\t\t);\n\t\tconst users = await apiFetch( { path } );\n\t\tdispatch.receiveUserQuery( path, users );\n\t};\n\n/**\n * Requests the current user from the REST API.\n */\nexport const getCurrentUser =\n\t() =>\n\tasync ( { dispatch } ) => {\n\t\tconst currentUser = await apiFetch( { path: '/wp/v2/users/me' } );\n\t\tdispatch.receiveCurrentUser( currentUser );\n\t};\n\n/**\n * Requests an entity's record from the REST API.\n *\n * @param {string} kind Entity kind.\n * @param {string} name Entity name.\n * @param {number|string} key Record's key\n * @param {Object|undefined} query Optional object of query parameters to\n * include with request. If requesting specific\n * fields, fields must always include the ID.\n */\nexport const getEntityRecord =\n\t( kind, name, key = '', query ) =>\n\tasync ( { select, dispatch } ) => {\n\t\tconst configs = await dispatch( getOrLoadEntitiesConfig( kind ) );\n\t\tconst entityConfig = configs.find(\n\t\t\t( config ) => config.name === name && config.kind === kind\n\t\t);\n\t\tif ( ! entityConfig || entityConfig?.__experimentalNoFetch ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst lock = await dispatch.__unstableAcquireStoreLock(\n\t\t\tSTORE_NAME,\n\t\t\t[ 'entities', 'records', kind, name, key ],\n\t\t\t{ exclusive: false }\n\t\t);\n\n\t\ttry {\n\t\t\tif ( query !== undefined && query._fields ) {\n\t\t\t\t// If requesting specific fields, items and query association to said\n\t\t\t\t// records are stored by ID reference. Thus, fields must always include\n\t\t\t\t// the ID.\n\t\t\t\tquery = {\n\t\t\t\t\t...query,\n\t\t\t\t\t_fields: [\n\t\t\t\t\t\t...new Set( [\n\t\t\t\t\t\t\t...( getNormalizedCommaSeparable( query._fields ) ||\n\t\t\t\t\t\t\t\t[] ),\n\t\t\t\t\t\t\tentityConfig.key || DEFAULT_ENTITY_KEY,\n\t\t\t\t\t\t] ),\n\t\t\t\t\t].join(),\n\t\t\t\t};\n\t\t\t}\n\n\t\t\t// Disable reason: While true that an early return could leave `path`\n\t\t\t// unused, it's important that path is derived using the query prior to\n\t\t\t// additional query modifications in the condition below, since those\n\t\t\t// modifications are relevant to how the data is tracked in state, and not\n\t\t\t// for how the request is made to the REST API.\n\n\t\t\t// eslint-disable-next-line @wordpress/no-unused-vars-before-return\n\t\t\tconst path = addQueryArgs(\n\t\t\t\tentityConfig.baseURL + ( key ? '/' + key : '' ),\n\t\t\t\t{\n\t\t\t\t\t...entityConfig.baseURLParams,\n\t\t\t\t\t...query,\n\t\t\t\t}\n\t\t\t);\n\n\t\t\tif ( query !== undefined ) {\n\t\t\t\tquery = { ...query, include: [ key ] };\n\n\t\t\t\t// The resolution cache won't consider query as reusable based on the\n\t\t\t\t// fields, so it's tested here, prior to initiating the REST request,\n\t\t\t\t// and without causing `getEntityRecords` resolution to occur.\n\t\t\t\tconst hasRecords = select.hasEntityRecords( kind, name, query );\n\t\t\t\tif ( hasRecords ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tconst record = await apiFetch( { path } );\n\t\t\tdispatch.receiveEntityRecords( kind, name, record, query );\n\t\t} finally {\n\t\t\tdispatch.__unstableReleaseStoreLock( lock );\n\t\t}\n\t};\n\n/**\n * Requests an entity's record from the REST API.\n */\nexport const getRawEntityRecord = forwardResolver( 'getEntityRecord' );\n\n/**\n * Requests an entity's record from the REST API.\n */\nexport const getEditedEntityRecord = forwardResolver( 'getEntityRecord' );\n\n/**\n * Requests the entity's records from the REST API.\n *\n * @param {string} kind Entity kind.\n * @param {string} name Entity name.\n * @param {Object?} query Query Object. If requesting specific fields, fields\n * must always include the ID.\n */\nexport const getEntityRecords =\n\t( kind, name, query = {} ) =>\n\tasync ( { dispatch } ) => {\n\t\tconst configs = await dispatch( getOrLoadEntitiesConfig( kind ) );\n\t\tconst entityConfig = configs.find(\n\t\t\t( config ) => config.name === name && config.kind === kind\n\t\t);\n\t\tif ( ! entityConfig || entityConfig?.__experimentalNoFetch ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst lock = await dispatch.__unstableAcquireStoreLock(\n\t\t\tSTORE_NAME,\n\t\t\t[ 'entities', 'records', kind, name ],\n\t\t\t{ exclusive: false }\n\t\t);\n\n\t\ttry {\n\t\t\tif ( query._fields ) {\n\t\t\t\t// If requesting specific fields, items and query association to said\n\t\t\t\t// records are stored by ID reference. Thus, fields must always include\n\t\t\t\t// the ID.\n\t\t\t\tquery = {\n\t\t\t\t\t...query,\n\t\t\t\t\t_fields: [\n\t\t\t\t\t\t...new Set( [\n\t\t\t\t\t\t\t...( getNormalizedCommaSeparable( query._fields ) ||\n\t\t\t\t\t\t\t\t[] ),\n\t\t\t\t\t\t\tentityConfig.key || DEFAULT_ENTITY_KEY,\n\t\t\t\t\t\t] ),\n\t\t\t\t\t].join(),\n\t\t\t\t};\n\t\t\t}\n\n\t\t\tconst path = addQueryArgs( entityConfig.baseURL, {\n\t\t\t\t...entityConfig.baseURLParams,\n\t\t\t\t...query,\n\t\t\t} );\n\n\t\t\tlet records = Object.values( await apiFetch( { path } ) );\n\t\t\t// If we request fields but the result doesn't contain the fields,\n\t\t\t// explicitly set these fields as \"undefined\"\n\t\t\t// that way we consider the query \"fullfilled\".\n\t\t\tif ( query._fields ) {\n\t\t\t\trecords = records.map( ( record ) => {\n\t\t\t\t\tquery._fields.split( ',' ).forEach( ( field ) => {\n\t\t\t\t\t\tif ( ! record.hasOwnProperty( field ) ) {\n\t\t\t\t\t\t\trecord[ field ] = undefined;\n\t\t\t\t\t\t}\n\t\t\t\t\t} );\n\n\t\t\t\t\treturn record;\n\t\t\t\t} );\n\t\t\t}\n\n\t\t\tdispatch.receiveEntityRecords( kind, name, records, query );\n\n\t\t\t// When requesting all fields, the list of results can be used to\n\t\t\t// resolve the `getEntityRecord` selector in addition to `getEntityRecords`.\n\t\t\t// See https://github.com/WordPress/gutenberg/pull/26575\n\t\t\tif ( ! query?._fields && ! query.context ) {\n\t\t\t\tconst key = entityConfig.key || DEFAULT_ENTITY_KEY;\n\t\t\t\tconst resolutionsArgs = records\n\t\t\t\t\t.filter( ( record ) => record[ key ] )\n\t\t\t\t\t.map( ( record ) => [ kind, name, record[ key ] ] );\n\n\t\t\t\tdispatch( {\n\t\t\t\t\ttype: 'START_RESOLUTIONS',\n\t\t\t\t\tselectorName: 'getEntityRecord',\n\t\t\t\t\targs: resolutionsArgs,\n\t\t\t\t} );\n\t\t\t\tdispatch( {\n\t\t\t\t\ttype: 'FINISH_RESOLUTIONS',\n\t\t\t\t\tselectorName: 'getEntityRecord',\n\t\t\t\t\targs: resolutionsArgs,\n\t\t\t\t} );\n\t\t\t}\n\t\t} finally {\n\t\t\tdispatch.__unstableReleaseStoreLock( lock );\n\t\t}\n\t};\n\ngetEntityRecords.shouldInvalidate = ( action, kind, name ) => {\n\treturn (\n\t\t( action.type === 'RECEIVE_ITEMS' || action.type === 'REMOVE_ITEMS' ) &&\n\t\taction.invalidateCache &&\n\t\tkind === action.kind &&\n\t\tname === action.name\n\t);\n};\n\n/**\n * Requests the current theme.\n */\nexport const getCurrentTheme =\n\t() =>\n\tasync ( { dispatch, resolveSelect } ) => {\n\t\tconst activeThemes = await resolveSelect.getEntityRecords(\n\t\t\t'root',\n\t\t\t'theme',\n\t\t\t{ status: 'active' }\n\t\t);\n\n\t\tdispatch.receiveCurrentTheme( activeThemes[ 0 ] );\n\t};\n\n/**\n * Requests theme supports data from the index.\n */\nexport const getThemeSupports = forwardResolver( 'getCurrentTheme' );\n\n/**\n * Requests a preview from the from the Embed API.\n *\n * @param {string} url URL to get the preview for.\n */\nexport const getEmbedPreview =\n\t( url ) =>\n\tasync ( { dispatch } ) => {\n\t\ttry {\n\t\t\tconst embedProxyResponse = await apiFetch( {\n\t\t\t\tpath: addQueryArgs( '/oembed/1.0/proxy', { url } ),\n\t\t\t} );\n\t\t\tdispatch.receiveEmbedPreview( url, embedProxyResponse );\n\t\t} catch ( error ) {\n\t\t\t// Embed API 404s if the URL cannot be embedded, so we have to catch the error from the apiRequest here.\n\t\t\tdispatch.receiveEmbedPreview( url, false );\n\t\t}\n\t};\n\n/**\n * Checks whether the current user can perform the given action on the given\n * REST resource.\n *\n * @param {string} requestedAction Action to check. One of: 'create', 'read', 'update',\n * 'delete'.\n * @param {string} resource REST resource to check, e.g. 'media' or 'posts'.\n * @param {?string} id ID of the rest resource to check.\n */\nexport const canUser =\n\t( requestedAction, resource, id ) =>\n\tasync ( { dispatch, registry } ) => {\n\t\tconst { hasStartedResolution } = registry.select( STORE_NAME );\n\n\t\tconst resourcePath = id ? `${ resource }/${ id }` : resource;\n\t\tconst retrievedActions = [ 'create', 'read', 'update', 'delete' ];\n\n\t\tif ( ! retrievedActions.includes( requestedAction ) ) {\n\t\t\tthrow new Error( `'${ requestedAction }' is not a valid action.` );\n\t\t}\n\n\t\t// Prevent resolving the same resource twice.\n\t\tfor ( const relatedAction of retrievedActions ) {\n\t\t\tif ( relatedAction === requestedAction ) {\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tconst isAlreadyResolving = hasStartedResolution( 'canUser', [\n\t\t\t\trelatedAction,\n\t\t\t\tresource,\n\t\t\t\tid,\n\t\t\t] );\n\t\t\tif ( isAlreadyResolving ) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t}\n\n\t\tlet response;\n\t\ttry {\n\t\t\tresponse = await apiFetch( {\n\t\t\t\tpath: `/wp/v2/${ resourcePath }`,\n\t\t\t\tmethod: 'OPTIONS',\n\t\t\t\tparse: false,\n\t\t\t} );\n\t\t} catch ( error ) {\n\t\t\t// Do nothing if our OPTIONS request comes back with an API error (4xx or\n\t\t\t// 5xx). The previously determined isAllowed value will remain in the store.\n\t\t\treturn;\n\t\t}\n\n\t\t// Optional chaining operator is used here because the API requests don't\n\t\t// return the expected result in the native version. Instead, API requests\n\t\t// only return the result, without including response properties like the headers.\n\t\tconst allowHeader = response.headers?.get( 'allow' );\n\t\tconst allowedMethods = allowHeader?.allow || allowHeader || '';\n\n\t\tconst permissions = {};\n\t\tconst methods = {\n\t\t\tcreate: 'POST',\n\t\t\tread: 'GET',\n\t\t\tupdate: 'PUT',\n\t\t\tdelete: 'DELETE',\n\t\t};\n\t\tfor ( const [ actionName, methodName ] of Object.entries( methods ) ) {\n\t\t\tpermissions[ actionName ] = allowedMethods.includes( methodName );\n\t\t}\n\n\t\tfor ( const action of retrievedActions ) {\n\t\t\tdispatch.receiveUserPermission(\n\t\t\t\t`${ action }/${ resourcePath }`,\n\t\t\t\tpermissions[ action ]\n\t\t\t);\n\t\t}\n\t};\n\n/**\n * Checks whether the current user can perform the given action on the given\n * REST resource.\n *\n * @param {string} kind Entity kind.\n * @param {string} name Entity name.\n * @param {string} recordId Record's id.\n */\nexport const canUserEditEntityRecord =\n\t( kind, name, recordId ) =>\n\tasync ( { dispatch } ) => {\n\t\tconst configs = await dispatch( getOrLoadEntitiesConfig( kind ) );\n\t\tconst entityConfig = configs.find(\n\t\t\t( config ) => config.name === name && config.kind === kind\n\t\t);\n\t\tif ( ! entityConfig ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst resource = entityConfig.__unstable_rest_base;\n\t\tawait dispatch( canUser( 'update', resource, recordId ) );\n\t};\n\n/**\n * Request autosave data from the REST API.\n *\n * @param {string} postType The type of the parent post.\n * @param {number} postId The id of the parent post.\n */\nexport const getAutosaves =\n\t( postType, postId ) =>\n\tasync ( { dispatch, resolveSelect } ) => {\n\t\tconst { rest_base: restBase, rest_namespace: restNamespace = 'wp/v2' } =\n\t\t\tawait resolveSelect.getPostType( postType );\n\t\tconst autosaves = await apiFetch( {\n\t\t\tpath: `/${ restNamespace }/${ restBase }/${ postId }/autosaves?context=edit`,\n\t\t} );\n\n\t\tif ( autosaves && autosaves.length ) {\n\t\t\tdispatch.receiveAutosaves( postId, autosaves );\n\t\t}\n\t};\n\n/**\n * Request autosave data from the REST API.\n *\n * This resolver exists to ensure the underlying autosaves are fetched via\n * `getAutosaves` when a call to the `getAutosave` selector is made.\n *\n * @param {string} postType The type of the parent post.\n * @param {number} postId The id of the parent post.\n */\nexport const getAutosave =\n\t( postType, postId ) =>\n\tasync ( { resolveSelect } ) => {\n\t\tawait resolveSelect.getAutosaves( postType, postId );\n\t};\n\n/**\n * Retrieve the frontend template used for a given link.\n *\n * @param {string} link Link.\n */\nexport const __experimentalGetTemplateForLink =\n\t( link ) =>\n\tasync ( { dispatch, resolveSelect } ) => {\n\t\tlet template;\n\t\ttry {\n\t\t\t// This is NOT calling a REST endpoint but rather ends up with a response from\n\t\t\t// an Ajax function which has a different shape from a WP_REST_Response.\n\t\t\ttemplate = await apiFetch( {\n\t\t\t\turl: addQueryArgs( link, {\n\t\t\t\t\t'_wp-find-template': true,\n\t\t\t\t} ),\n\t\t\t} ).then( ( { data } ) => data );\n\t\t} catch ( e ) {\n\t\t\t// For non-FSE themes, it is possible that this request returns an error.\n\t\t}\n\n\t\tif ( ! template ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst record = await resolveSelect.getEntityRecord(\n\t\t\t'postType',\n\t\t\t'wp_template',\n\t\t\ttemplate.id\n\t\t);\n\n\t\tif ( record ) {\n\t\t\tdispatch.receiveEntityRecords(\n\t\t\t\t'postType',\n\t\t\t\t'wp_template',\n\t\t\t\t[ record ],\n\t\t\t\t{\n\t\t\t\t\t'find-template': link,\n\t\t\t\t}\n\t\t\t);\n\t\t}\n\t};\n\n__experimentalGetTemplateForLink.shouldInvalidate = ( action ) => {\n\treturn (\n\t\t( action.type === 'RECEIVE_ITEMS' || action.type === 'REMOVE_ITEMS' ) &&\n\t\taction.invalidateCache &&\n\t\taction.kind === 'postType' &&\n\t\taction.name === 'wp_template'\n\t);\n};\n\nexport const __experimentalGetCurrentGlobalStylesId =\n\t() =>\n\tasync ( { dispatch, resolveSelect } ) => {\n\t\tconst activeThemes = await resolveSelect.getEntityRecords(\n\t\t\t'root',\n\t\t\t'theme',\n\t\t\t{ status: 'active' }\n\t\t);\n\t\tconst globalStylesURL =\n\t\t\tactiveThemes?.[ 0 ]?._links?.[ 'wp:user-global-styles' ]?.[ 0 ]\n\t\t\t\t?.href;\n\t\tif ( globalStylesURL ) {\n\t\t\tconst globalStylesObject = await apiFetch( {\n\t\t\t\turl: globalStylesURL,\n\t\t\t} );\n\t\t\tdispatch.__experimentalReceiveCurrentGlobalStylesId(\n\t\t\t\tglobalStylesObject.id\n\t\t\t);\n\t\t}\n\t};\n\nexport const __experimentalGetCurrentThemeBaseGlobalStyles =\n\t() =>\n\tasync ( { resolveSelect, dispatch } ) => {\n\t\tconst currentTheme = await resolveSelect.getCurrentTheme();\n\t\tconst themeGlobalStyles = await apiFetch( {\n\t\t\tpath: `/wp/v2/global-styles/themes/${ currentTheme.stylesheet }`,\n\t\t} );\n\t\tdispatch.__experimentalReceiveThemeBaseGlobalStyles(\n\t\t\tcurrentTheme.stylesheet,\n\t\t\tthemeGlobalStyles\n\t\t);\n\t};\n\nexport const __experimentalGetCurrentThemeGlobalStylesVariations =\n\t() =>\n\tasync ( { resolveSelect, dispatch } ) => {\n\t\tconst currentTheme = await resolveSelect.getCurrentTheme();\n\t\tconst variations = await apiFetch( {\n\t\t\tpath: `/wp/v2/global-styles/themes/${ currentTheme.stylesheet }/variations`,\n\t\t} );\n\t\tdispatch.__experimentalReceiveThemeGlobalStyleVariations(\n\t\t\tcurrentTheme.stylesheet,\n\t\t\tvariations\n\t\t);\n\t};\n\n/**\n * Fetches and returns the revisions of the current global styles theme.\n */\nexport const getCurrentThemeGlobalStylesRevisions =\n\t() =>\n\tasync ( { resolveSelect, dispatch } ) => {\n\t\tconst globalStylesId =\n\t\t\tawait resolveSelect.__experimentalGetCurrentGlobalStylesId();\n\t\tconst record = globalStylesId\n\t\t\t? await resolveSelect.getEntityRecord(\n\t\t\t\t\t'root',\n\t\t\t\t\t'globalStyles',\n\t\t\t\t\tglobalStylesId\n\t\t\t )\n\t\t\t: undefined;\n\t\tconst revisionsURL = record?._links?.[ 'version-history' ]?.[ 0 ]?.href;\n\n\t\tif ( revisionsURL ) {\n\t\t\tconst resetRevisions = await apiFetch( {\n\t\t\t\turl: revisionsURL,\n\t\t\t} );\n\t\t\tconst revisions = resetRevisions?.map( ( revision ) =>\n\t\t\t\tObject.fromEntries(\n\t\t\t\t\tObject.entries( revision ).map( ( [ key, value ] ) => [\n\t\t\t\t\t\tcamelCase( key ),\n\t\t\t\t\t\tvalue,\n\t\t\t\t\t] )\n\t\t\t\t)\n\t\t\t);\n\t\t\tdispatch.receiveThemeGlobalStyleRevisions(\n\t\t\t\tglobalStylesId,\n\t\t\t\trevisions\n\t\t\t);\n\t\t}\n\t};\n\ngetCurrentThemeGlobalStylesRevisions.shouldInvalidate = ( action ) => {\n\treturn (\n\t\taction.type === 'SAVE_ENTITY_RECORD_FINISH' &&\n\t\taction.kind === 'root' &&\n\t\t! action.error &&\n\t\taction.name === 'globalStyles'\n\t);\n};\n\nexport const getBlockPatterns =\n\t() =>\n\tasync ( { dispatch } ) => {\n\t\tconst restPatterns = await apiFetch( {\n\t\t\tpath: '/wp/v2/block-patterns/patterns',\n\t\t} );\n\t\tconst patterns = restPatterns?.map( ( pattern ) =>\n\t\t\tObject.fromEntries(\n\t\t\t\tObject.entries( pattern ).map( ( [ key, value ] ) => [\n\t\t\t\t\tcamelCase( key ),\n\t\t\t\t\tvalue,\n\t\t\t\t] )\n\t\t\t)\n\t\t);\n\t\tdispatch( { type: 'RECEIVE_BLOCK_PATTERNS', patterns } );\n\t};\n\nexport const getBlockPatternCategories =\n\t() =>\n\tasync ( { dispatch } ) => {\n\t\tconst categories = await apiFetch( {\n\t\t\tpath: '/wp/v2/block-patterns/categories',\n\t\t} );\n\t\tdispatch( { type: 'RECEIVE_BLOCK_PATTERN_CATEGORIES', categories } );\n\t};\n\nexport const getNavigationFallbackId =\n\t() =>\n\tasync ( { dispatch } ) => {\n\t\tconst fallback = await apiFetch( {\n\t\t\tpath: addQueryArgs( '/wp-block-editor/v1/navigation-fallback', {\n\t\t\t\t_embed: true,\n\t\t\t} ),\n\t\t} );\n\n\t\tconst record = fallback?._embedded?.self;\n\n\t\tdispatch.receiveNavigationFallbackId( fallback?.id );\n\n\t\tif ( record ) {\n\t\t\tdispatch.receiveEntityRecords(\n\t\t\t\t'postType',\n\t\t\t\t'wp_navigation',\n\t\t\t\trecord\n\t\t\t);\n\n\t\t\t// Resolve to avoid further network requests.\n\t\t\tdispatch.finishResolution( 'getEntityRecord', [\n\t\t\t\t'postType',\n\t\t\t\t'wp_navigation',\n\t\t\t\tfallback?.id,\n\t\t\t] );\n\t\t}\n\t};\n"]}
1
+ {"version":3,"sources":["@wordpress/core-data/src/resolvers.js"],"names":["camelCase","addQueryArgs","apiFetch","STORE_NAME","getOrLoadEntitiesConfig","DEFAULT_ENTITY_KEY","forwardResolver","getNormalizedCommaSeparable","getAuthors","query","dispatch","path","users","receiveUserQuery","getCurrentUser","currentUser","receiveCurrentUser","getEntityRecord","kind","name","key","select","configs","entityConfig","find","config","__experimentalNoFetch","lock","__unstableAcquireStoreLock","exclusive","undefined","_fields","Set","join","baseURL","baseURLParams","include","hasRecords","hasEntityRecords","record","receiveEntityRecords","__unstableReleaseStoreLock","getRawEntityRecord","getEditedEntityRecord","getEntityRecords","records","Object","values","map","split","forEach","field","hasOwnProperty","context","resolutionsArgs","filter","type","selectorName","args","shouldInvalidate","action","invalidateCache","getCurrentTheme","resolveSelect","activeThemes","status","receiveCurrentTheme","getThemeSupports","getEmbedPreview","url","embedProxyResponse","receiveEmbedPreview","error","canUser","requestedAction","resource","id","registry","hasStartedResolution","resourcePath","retrievedActions","includes","Error","relatedAction","isAlreadyResolving","response","method","parse","allowHeader","headers","get","allowedMethods","allow","permissions","methods","create","read","update","delete","actionName","methodName","entries","receiveUserPermission","canUserEditEntityRecord","recordId","__unstable_rest_base","getAutosaves","postType","postId","rest_base","restBase","rest_namespace","restNamespace","getPostType","autosaves","length","receiveAutosaves","getAutosave","__experimentalGetTemplateForLink","link","template","then","data","e","__experimentalGetCurrentGlobalStylesId","globalStylesURL","_links","href","globalStylesObject","__experimentalReceiveCurrentGlobalStylesId","__experimentalGetCurrentThemeBaseGlobalStyles","currentTheme","themeGlobalStyles","stylesheet","__experimentalReceiveThemeBaseGlobalStyles","__experimentalGetCurrentThemeGlobalStylesVariations","variations","__experimentalReceiveThemeGlobalStyleVariations","getCurrentThemeGlobalStylesRevisions","globalStylesId","revisionsURL","resetRevisions","revisions","revision","fromEntries","value","receiveThemeGlobalStyleRevisions","getBlockPatterns","restPatterns","patterns","pattern","getBlockPatternCategories","categories","getNavigationFallbackId","fallback","_embed","_embedded","self","receiveNavigationFallbackId","finishResolution"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,SAAT,QAA0B,aAA1B;AAEA;AACA;AACA;;AACA,SAASC,YAAT,QAA6B,gBAA7B;AACA,OAAOC,QAAP,MAAqB,sBAArB;AAEA;AACA;AACA;;AACA,SAASC,UAAT,QAA2B,QAA3B;AACA,SAASC,uBAAT,EAAkCC,kBAAlC,QAA4D,YAA5D;AACA,SAASC,eAAT,EAA0BC,2BAA1B,QAA6D,SAA7D;AAEA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,MAAMC,UAAU,GACpBC,KAAF,IACA,OAAQ;AAAEC,EAAAA;AAAF,CAAR,KAA0B;AACzB,QAAMC,IAAI,GAAGV,YAAY,CACxB,wCADwB,EAExBQ,KAFwB,CAAzB;AAIA,QAAMG,KAAK,GAAG,MAAMV,QAAQ,CAAE;AAAES,IAAAA;AAAF,GAAF,CAA5B;AACAD,EAAAA,QAAQ,CAACG,gBAAT,CAA2BF,IAA3B,EAAiCC,KAAjC;AACA,CATK;AAWP;AACA;AACA;;AACA,OAAO,MAAME,cAAc,GAC1B,MACA,OAAQ;AAAEJ,EAAAA;AAAF,CAAR,KAA0B;AACzB,QAAMK,WAAW,GAAG,MAAMb,QAAQ,CAAE;AA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AR,KAA0B;AACzB,QAAMgJ,QAAQ,GAAG,MAAMxJ,QAAQ,CAAE;AAChCS,IAAAA,IAAI,EAAEV,YAAY,CAAE,yCAAF,EAA6C;AAC9D0J,MAAAA,MAAM,EAAE;AADsD,KAA7C;AADc,GAAF,CAA/B;AAMA,QAAMpH,MAAM,GAAGmH,QAAQ,EAAEE,SAAV,EAAqBC,IAApC;AAEAnJ,EAAAA,QAAQ,CAACoJ,2BAAT,CAAsCJ,QAAQ,EAAE9E,EAAhD;;AAEA,MAAKrC,MAAL,EAAc;AACb7B,IAAAA,QAAQ,CAAC8B,oBAAT,CACC,UADD,EAEC,eAFD,EAGCD,MAHD,EADa,CAOb;;AACA7B,IAAAA,QAAQ,CAACqJ,gBAAT,CAA2B,iBAA3B,EAA8C,CAC7C,UAD6C,EAE7C,eAF6C,EAG7CL,QAAQ,EAAE9E,EAHmC,CAA9C;AAKA;AACD,CA3BK","sourcesContent":["/**\n * External dependencies\n */\nimport { camelCase } from 'change-case';\n\n/**\n * WordPress dependencies\n */\nimport { addQueryArgs } from '@wordpress/url';\nimport apiFetch from '@wordpress/api-fetch';\n\n/**\n * Internal dependencies\n */\nimport { STORE_NAME } from './name';\nimport { getOrLoadEntitiesConfig, DEFAULT_ENTITY_KEY } from './entities';\nimport { forwardResolver, getNormalizedCommaSeparable } from './utils';\n\n/**\n * Requests authors from the REST API.\n *\n * @param {Object|undefined} query Optional object of query parameters to\n * include with request.\n */\nexport const getAuthors =\n\t( query ) =>\n\tasync ( { dispatch } ) => {\n\t\tconst path = addQueryArgs(\n\t\t\t'/wp/v2/users/?who=authors&per_page=100',\n\t\t\tquery\n\t\t);\n\t\tconst users = await apiFetch( { path } );\n\t\tdispatch.receiveUserQuery( path, users );\n\t};\n\n/**\n * Requests the current user from the REST API.\n */\nexport const getCurrentUser =\n\t() =>\n\tasync ( { dispatch } ) => {\n\t\tconst currentUser = await apiFetch( { path: '/wp/v2/users/me' } );\n\t\tdispatch.receiveCurrentUser( currentUser );\n\t};\n\n/**\n * Requests an entity's record from the REST API.\n *\n * @param {string} kind Entity kind.\n * @param {string} name Entity name.\n * @param {number|string} key Record's key\n * @param {Object|undefined} query Optional object of query parameters to\n * include with request. If requesting specific\n * fields, fields must always include the ID.\n */\nexport const getEntityRecord =\n\t( kind, name, key = '', query ) =>\n\tasync ( { select, dispatch } ) => {\n\t\tconst configs = await dispatch( getOrLoadEntitiesConfig( kind ) );\n\t\tconst entityConfig = configs.find(\n\t\t\t( config ) => config.name === name && config.kind === kind\n\t\t);\n\t\tif ( ! entityConfig || entityConfig?.__experimentalNoFetch ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst lock = await dispatch.__unstableAcquireStoreLock(\n\t\t\tSTORE_NAME,\n\t\t\t[ 'entities', 'records', kind, name, key ],\n\t\t\t{ exclusive: false }\n\t\t);\n\n\t\ttry {\n\t\t\tif ( query !== undefined && query._fields ) {\n\t\t\t\t// If requesting specific fields, items and query association to said\n\t\t\t\t// records are stored by ID reference. Thus, fields must always include\n\t\t\t\t// the ID.\n\t\t\t\tquery = {\n\t\t\t\t\t...query,\n\t\t\t\t\t_fields: [\n\t\t\t\t\t\t...new Set( [\n\t\t\t\t\t\t\t...( getNormalizedCommaSeparable( query._fields ) ||\n\t\t\t\t\t\t\t\t[] ),\n\t\t\t\t\t\t\tentityConfig.key || DEFAULT_ENTITY_KEY,\n\t\t\t\t\t\t] ),\n\t\t\t\t\t].join(),\n\t\t\t\t};\n\t\t\t}\n\n\t\t\t// Disable reason: While true that an early return could leave `path`\n\t\t\t// unused, it's important that path is derived using the query prior to\n\t\t\t// additional query modifications in the condition below, since those\n\t\t\t// modifications are relevant to how the data is tracked in state, and not\n\t\t\t// for how the request is made to the REST API.\n\n\t\t\t// eslint-disable-next-line @wordpress/no-unused-vars-before-return\n\t\t\tconst path = addQueryArgs(\n\t\t\t\tentityConfig.baseURL + ( key ? '/' + key : '' ),\n\t\t\t\t{\n\t\t\t\t\t...entityConfig.baseURLParams,\n\t\t\t\t\t...query,\n\t\t\t\t}\n\t\t\t);\n\n\t\t\tif ( query !== undefined ) {\n\t\t\t\tquery = { ...query, include: [ key ] };\n\n\t\t\t\t// The resolution cache won't consider query as reusable based on the\n\t\t\t\t// fields, so it's tested here, prior to initiating the REST request,\n\t\t\t\t// and without causing `getEntityRecords` resolution to occur.\n\t\t\t\tconst hasRecords = select.hasEntityRecords( kind, name, query );\n\t\t\t\tif ( hasRecords ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tconst record = await apiFetch( { path } );\n\t\t\tdispatch.receiveEntityRecords( kind, name, record, query );\n\t\t} finally {\n\t\t\tdispatch.__unstableReleaseStoreLock( lock );\n\t\t}\n\t};\n\n/**\n * Requests an entity's record from the REST API.\n */\nexport const getRawEntityRecord = forwardResolver( 'getEntityRecord' );\n\n/**\n * Requests an entity's record from the REST API.\n */\nexport const getEditedEntityRecord = forwardResolver( 'getEntityRecord' );\n\n/**\n * Requests the entity's records from the REST API.\n *\n * @param {string} kind Entity kind.\n * @param {string} name Entity name.\n * @param {Object?} query Query Object. If requesting specific fields, fields\n * must always include the ID.\n */\nexport const getEntityRecords =\n\t( kind, name, query = {} ) =>\n\tasync ( { dispatch } ) => {\n\t\tconst configs = await dispatch( getOrLoadEntitiesConfig( kind ) );\n\t\tconst entityConfig = configs.find(\n\t\t\t( config ) => config.name === name && config.kind === kind\n\t\t);\n\t\tif ( ! entityConfig || entityConfig?.__experimentalNoFetch ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst lock = await dispatch.__unstableAcquireStoreLock(\n\t\t\tSTORE_NAME,\n\t\t\t[ 'entities', 'records', kind, name ],\n\t\t\t{ exclusive: false }\n\t\t);\n\n\t\ttry {\n\t\t\tif ( query._fields ) {\n\t\t\t\t// If requesting specific fields, items and query association to said\n\t\t\t\t// records are stored by ID reference. Thus, fields must always include\n\t\t\t\t// the ID.\n\t\t\t\tquery = {\n\t\t\t\t\t...query,\n\t\t\t\t\t_fields: [\n\t\t\t\t\t\t...new Set( [\n\t\t\t\t\t\t\t...( getNormalizedCommaSeparable( query._fields ) ||\n\t\t\t\t\t\t\t\t[] ),\n\t\t\t\t\t\t\tentityConfig.key || DEFAULT_ENTITY_KEY,\n\t\t\t\t\t\t] ),\n\t\t\t\t\t].join(),\n\t\t\t\t};\n\t\t\t}\n\n\t\t\tconst path = addQueryArgs( entityConfig.baseURL, {\n\t\t\t\t...entityConfig.baseURLParams,\n\t\t\t\t...query,\n\t\t\t} );\n\n\t\t\tlet records = Object.values( await apiFetch( { path } ) );\n\t\t\t// If we request fields but the result doesn't contain the fields,\n\t\t\t// explicitly set these fields as \"undefined\"\n\t\t\t// that way we consider the query \"fullfilled\".\n\t\t\tif ( query._fields ) {\n\t\t\t\trecords = records.map( ( record ) => {\n\t\t\t\t\tquery._fields.split( ',' ).forEach( ( field ) => {\n\t\t\t\t\t\tif ( ! record.hasOwnProperty( field ) ) {\n\t\t\t\t\t\t\trecord[ field ] = undefined;\n\t\t\t\t\t\t}\n\t\t\t\t\t} );\n\n\t\t\t\t\treturn record;\n\t\t\t\t} );\n\t\t\t}\n\n\t\t\tdispatch.receiveEntityRecords( kind, name, records, query );\n\n\t\t\t// When requesting all fields, the list of results can be used to\n\t\t\t// resolve the `getEntityRecord` selector in addition to `getEntityRecords`.\n\t\t\t// See https://github.com/WordPress/gutenberg/pull/26575\n\t\t\tif ( ! query?._fields && ! query.context ) {\n\t\t\t\tconst key = entityConfig.key || DEFAULT_ENTITY_KEY;\n\t\t\t\tconst resolutionsArgs = records\n\t\t\t\t\t.filter( ( record ) => record[ key ] )\n\t\t\t\t\t.map( ( record ) => [ kind, name, record[ key ] ] );\n\n\t\t\t\tdispatch( {\n\t\t\t\t\ttype: 'START_RESOLUTIONS',\n\t\t\t\t\tselectorName: 'getEntityRecord',\n\t\t\t\t\targs: resolutionsArgs,\n\t\t\t\t} );\n\t\t\t\tdispatch( {\n\t\t\t\t\ttype: 'FINISH_RESOLUTIONS',\n\t\t\t\t\tselectorName: 'getEntityRecord',\n\t\t\t\t\targs: resolutionsArgs,\n\t\t\t\t} );\n\t\t\t}\n\t\t} finally {\n\t\t\tdispatch.__unstableReleaseStoreLock( lock );\n\t\t}\n\t};\n\ngetEntityRecords.shouldInvalidate = ( action, kind, name ) => {\n\treturn (\n\t\t( action.type === 'RECEIVE_ITEMS' || action.type === 'REMOVE_ITEMS' ) &&\n\t\taction.invalidateCache &&\n\t\tkind === action.kind &&\n\t\tname === action.name\n\t);\n};\n\n/**\n * Requests the current theme.\n */\nexport const getCurrentTheme =\n\t() =>\n\tasync ( { dispatch, resolveSelect } ) => {\n\t\tconst activeThemes = await resolveSelect.getEntityRecords(\n\t\t\t'root',\n\t\t\t'theme',\n\t\t\t{ status: 'active' }\n\t\t);\n\n\t\tdispatch.receiveCurrentTheme( activeThemes[ 0 ] );\n\t};\n\n/**\n * Requests theme supports data from the index.\n */\nexport const getThemeSupports = forwardResolver( 'getCurrentTheme' );\n\n/**\n * Requests a preview from the from the Embed API.\n *\n * @param {string} url URL to get the preview for.\n */\nexport const getEmbedPreview =\n\t( url ) =>\n\tasync ( { dispatch } ) => {\n\t\ttry {\n\t\t\tconst embedProxyResponse = await apiFetch( {\n\t\t\t\tpath: addQueryArgs( '/oembed/1.0/proxy', { url } ),\n\t\t\t} );\n\t\t\tdispatch.receiveEmbedPreview( url, embedProxyResponse );\n\t\t} catch ( error ) {\n\t\t\t// Embed API 404s if the URL cannot be embedded, so we have to catch the error from the apiRequest here.\n\t\t\tdispatch.receiveEmbedPreview( url, false );\n\t\t}\n\t};\n\n/**\n * Checks whether the current user can perform the given action on the given\n * REST resource.\n *\n * @param {string} requestedAction Action to check. One of: 'create', 'read', 'update',\n * 'delete'.\n * @param {string} resource REST resource to check, e.g. 'media' or 'posts'.\n * @param {?string} id ID of the rest resource to check.\n */\nexport const canUser =\n\t( requestedAction, resource, id ) =>\n\tasync ( { dispatch, registry } ) => {\n\t\tconst { hasStartedResolution } = registry.select( STORE_NAME );\n\n\t\tconst resourcePath = id ? `${ resource }/${ id }` : resource;\n\t\tconst retrievedActions = [ 'create', 'read', 'update', 'delete' ];\n\n\t\tif ( ! retrievedActions.includes( requestedAction ) ) {\n\t\t\tthrow new Error( `'${ requestedAction }' is not a valid action.` );\n\t\t}\n\n\t\t// Prevent resolving the same resource twice.\n\t\tfor ( const relatedAction of retrievedActions ) {\n\t\t\tif ( relatedAction === requestedAction ) {\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tconst isAlreadyResolving = hasStartedResolution( 'canUser', [\n\t\t\t\trelatedAction,\n\t\t\t\tresource,\n\t\t\t\tid,\n\t\t\t] );\n\t\t\tif ( isAlreadyResolving ) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t}\n\n\t\tlet response;\n\t\ttry {\n\t\t\tresponse = await apiFetch( {\n\t\t\t\tpath: `/wp/v2/${ resourcePath }`,\n\t\t\t\tmethod: 'OPTIONS',\n\t\t\t\tparse: false,\n\t\t\t} );\n\t\t} catch ( error ) {\n\t\t\t// Do nothing if our OPTIONS request comes back with an API error (4xx or\n\t\t\t// 5xx). The previously determined isAllowed value will remain in the store.\n\t\t\treturn;\n\t\t}\n\n\t\t// Optional chaining operator is used here because the API requests don't\n\t\t// return the expected result in the native version. Instead, API requests\n\t\t// only return the result, without including response properties like the headers.\n\t\tconst allowHeader = response.headers?.get( 'allow' );\n\t\tconst allowedMethods = allowHeader?.allow || allowHeader || '';\n\n\t\tconst permissions = {};\n\t\tconst methods = {\n\t\t\tcreate: 'POST',\n\t\t\tread: 'GET',\n\t\t\tupdate: 'PUT',\n\t\t\tdelete: 'DELETE',\n\t\t};\n\t\tfor ( const [ actionName, methodName ] of Object.entries( methods ) ) {\n\t\t\tpermissions[ actionName ] = allowedMethods.includes( methodName );\n\t\t}\n\n\t\tfor ( const action of retrievedActions ) {\n\t\t\tdispatch.receiveUserPermission(\n\t\t\t\t`${ action }/${ resourcePath }`,\n\t\t\t\tpermissions[ action ]\n\t\t\t);\n\t\t}\n\t};\n\n/**\n * Checks whether the current user can perform the given action on the given\n * REST resource.\n *\n * @param {string} kind Entity kind.\n * @param {string} name Entity name.\n * @param {string} recordId Record's id.\n */\nexport const canUserEditEntityRecord =\n\t( kind, name, recordId ) =>\n\tasync ( { dispatch } ) => {\n\t\tconst configs = await dispatch( getOrLoadEntitiesConfig( kind ) );\n\t\tconst entityConfig = configs.find(\n\t\t\t( config ) => config.name === name && config.kind === kind\n\t\t);\n\t\tif ( ! entityConfig ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst resource = entityConfig.__unstable_rest_base;\n\t\tawait dispatch( canUser( 'update', resource, recordId ) );\n\t};\n\n/**\n * Request autosave data from the REST API.\n *\n * @param {string} postType The type of the parent post.\n * @param {number} postId The id of the parent post.\n */\nexport const getAutosaves =\n\t( postType, postId ) =>\n\tasync ( { dispatch, resolveSelect } ) => {\n\t\tconst { rest_base: restBase, rest_namespace: restNamespace = 'wp/v2' } =\n\t\t\tawait resolveSelect.getPostType( postType );\n\t\tconst autosaves = await apiFetch( {\n\t\t\tpath: `/${ restNamespace }/${ restBase }/${ postId }/autosaves?context=edit`,\n\t\t} );\n\n\t\tif ( autosaves && autosaves.length ) {\n\t\t\tdispatch.receiveAutosaves( postId, autosaves );\n\t\t}\n\t};\n\n/**\n * Request autosave data from the REST API.\n *\n * This resolver exists to ensure the underlying autosaves are fetched via\n * `getAutosaves` when a call to the `getAutosave` selector is made.\n *\n * @param {string} postType The type of the parent post.\n * @param {number} postId The id of the parent post.\n */\nexport const getAutosave =\n\t( postType, postId ) =>\n\tasync ( { resolveSelect } ) => {\n\t\tawait resolveSelect.getAutosaves( postType, postId );\n\t};\n\n/**\n * Retrieve the frontend template used for a given link.\n *\n * @param {string} link Link.\n */\nexport const __experimentalGetTemplateForLink =\n\t( link ) =>\n\tasync ( { dispatch, resolveSelect } ) => {\n\t\tlet template;\n\t\ttry {\n\t\t\t// This is NOT calling a REST endpoint but rather ends up with a response from\n\t\t\t// an Ajax function which has a different shape from a WP_REST_Response.\n\t\t\ttemplate = await apiFetch( {\n\t\t\t\turl: addQueryArgs( link, {\n\t\t\t\t\t'_wp-find-template': true,\n\t\t\t\t} ),\n\t\t\t} ).then( ( { data } ) => data );\n\t\t} catch ( e ) {\n\t\t\t// For non-FSE themes, it is possible that this request returns an error.\n\t\t}\n\n\t\tif ( ! template ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst record = await resolveSelect.getEntityRecord(\n\t\t\t'postType',\n\t\t\t'wp_template',\n\t\t\ttemplate.id\n\t\t);\n\n\t\tif ( record ) {\n\t\t\tdispatch.receiveEntityRecords(\n\t\t\t\t'postType',\n\t\t\t\t'wp_template',\n\t\t\t\t[ record ],\n\t\t\t\t{\n\t\t\t\t\t'find-template': link,\n\t\t\t\t}\n\t\t\t);\n\t\t}\n\t};\n\n__experimentalGetTemplateForLink.shouldInvalidate = ( action ) => {\n\treturn (\n\t\t( action.type === 'RECEIVE_ITEMS' || action.type === 'REMOVE_ITEMS' ) &&\n\t\taction.invalidateCache &&\n\t\taction.kind === 'postType' &&\n\t\taction.name === 'wp_template'\n\t);\n};\n\nexport const __experimentalGetCurrentGlobalStylesId =\n\t() =>\n\tasync ( { dispatch, resolveSelect } ) => {\n\t\tconst activeThemes = await resolveSelect.getEntityRecords(\n\t\t\t'root',\n\t\t\t'theme',\n\t\t\t{ status: 'active' }\n\t\t);\n\t\tconst globalStylesURL =\n\t\t\tactiveThemes?.[ 0 ]?._links?.[ 'wp:user-global-styles' ]?.[ 0 ]\n\t\t\t\t?.href;\n\t\tif ( globalStylesURL ) {\n\t\t\tconst globalStylesObject = await apiFetch( {\n\t\t\t\turl: globalStylesURL,\n\t\t\t} );\n\t\t\tdispatch.__experimentalReceiveCurrentGlobalStylesId(\n\t\t\t\tglobalStylesObject.id\n\t\t\t);\n\t\t}\n\t};\n\nexport const __experimentalGetCurrentThemeBaseGlobalStyles =\n\t() =>\n\tasync ( { resolveSelect, dispatch } ) => {\n\t\tconst currentTheme = await resolveSelect.getCurrentTheme();\n\t\tconst themeGlobalStyles = await apiFetch( {\n\t\t\tpath: `/wp/v2/global-styles/themes/${ currentTheme.stylesheet }`,\n\t\t} );\n\t\tdispatch.__experimentalReceiveThemeBaseGlobalStyles(\n\t\t\tcurrentTheme.stylesheet,\n\t\t\tthemeGlobalStyles\n\t\t);\n\t};\n\nexport const __experimentalGetCurrentThemeGlobalStylesVariations =\n\t() =>\n\tasync ( { resolveSelect, dispatch } ) => {\n\t\tconst currentTheme = await resolveSelect.getCurrentTheme();\n\t\tconst variations = await apiFetch( {\n\t\t\tpath: `/wp/v2/global-styles/themes/${ currentTheme.stylesheet }/variations`,\n\t\t} );\n\t\tdispatch.__experimentalReceiveThemeGlobalStyleVariations(\n\t\t\tcurrentTheme.stylesheet,\n\t\t\tvariations\n\t\t);\n\t};\n\n/**\n * Fetches and returns the revisions of the current global styles theme.\n */\nexport const getCurrentThemeGlobalStylesRevisions =\n\t() =>\n\tasync ( { resolveSelect, dispatch } ) => {\n\t\tconst globalStylesId =\n\t\t\tawait resolveSelect.__experimentalGetCurrentGlobalStylesId();\n\t\tconst record = globalStylesId\n\t\t\t? await resolveSelect.getEntityRecord(\n\t\t\t\t\t'root',\n\t\t\t\t\t'globalStyles',\n\t\t\t\t\tglobalStylesId\n\t\t\t )\n\t\t\t: undefined;\n\t\tconst revisionsURL = record?._links?.[ 'version-history' ]?.[ 0 ]?.href;\n\n\t\tif ( revisionsURL ) {\n\t\t\tconst resetRevisions = await apiFetch( {\n\t\t\t\turl: revisionsURL,\n\t\t\t} );\n\t\t\tconst revisions = resetRevisions?.map( ( revision ) =>\n\t\t\t\tObject.fromEntries(\n\t\t\t\t\tObject.entries( revision ).map( ( [ key, value ] ) => [\n\t\t\t\t\t\tcamelCase( key ),\n\t\t\t\t\t\tvalue,\n\t\t\t\t\t] )\n\t\t\t\t)\n\t\t\t);\n\t\t\tdispatch.receiveThemeGlobalStyleRevisions(\n\t\t\t\tglobalStylesId,\n\t\t\t\trevisions\n\t\t\t);\n\t\t}\n\t};\n\ngetCurrentThemeGlobalStylesRevisions.shouldInvalidate = ( action ) => {\n\treturn (\n\t\taction.type === 'SAVE_ENTITY_RECORD_FINISH' &&\n\t\taction.kind === 'root' &&\n\t\t! action.error &&\n\t\taction.name === 'globalStyles'\n\t);\n};\n\nexport const getBlockPatterns =\n\t() =>\n\tasync ( { dispatch } ) => {\n\t\tconst restPatterns = await apiFetch( {\n\t\t\tpath: '/wp/v2/block-patterns/patterns',\n\t\t} );\n\t\tconst patterns = restPatterns?.map( ( pattern ) =>\n\t\t\tObject.fromEntries(\n\t\t\t\tObject.entries( pattern ).map( ( [ key, value ] ) => [\n\t\t\t\t\tcamelCase( key ),\n\t\t\t\t\tvalue,\n\t\t\t\t] )\n\t\t\t)\n\t\t);\n\t\tdispatch( { type: 'RECEIVE_BLOCK_PATTERNS', patterns } );\n\t};\n\nexport const getBlockPatternCategories =\n\t() =>\n\tasync ( { dispatch } ) => {\n\t\tconst categories = await apiFetch( {\n\t\t\tpath: '/wp/v2/block-patterns/categories',\n\t\t} );\n\t\tdispatch( { type: 'RECEIVE_BLOCK_PATTERN_CATEGORIES', categories } );\n\t};\n\nexport const getNavigationFallbackId =\n\t() =>\n\tasync ( { dispatch } ) => {\n\t\tconst fallback = await apiFetch( {\n\t\t\tpath: addQueryArgs( '/wp-block-editor/v1/navigation-fallback', {\n\t\t\t\t_embed: true,\n\t\t\t} ),\n\t\t} );\n\n\t\tconst record = fallback?._embedded?.self;\n\n\t\tdispatch.receiveNavigationFallbackId( fallback?.id );\n\n\t\tif ( record ) {\n\t\t\tdispatch.receiveEntityRecords(\n\t\t\t\t'postType',\n\t\t\t\t'wp_navigation',\n\t\t\t\trecord\n\t\t\t);\n\n\t\t\t// Resolve to avoid further network requests.\n\t\t\tdispatch.finishResolution( 'getEntityRecord', [\n\t\t\t\t'postType',\n\t\t\t\t'wp_navigation',\n\t\t\t\tfallback?.id,\n\t\t\t] );\n\t\t}\n\t};\n"]}
@@ -17,6 +17,10 @@ import { STORE_NAME } from './name';
17
17
  import { getQueriedItems } from './queried-data';
18
18
  import { DEFAULT_ENTITY_KEY } from './entities';
19
19
  import { getNormalizedCommaSeparable, isRawAttribute, setNestedValue } from './utils';
20
+ import { getUndoEdits, getRedoEdits } from './private-selectors'; // This is an incomplete, high-level approximation of the State type.
21
+ // It makes the selectors slightly more safe, but is intended to evolve
22
+ // into a more detailed representation over time.
23
+ // See https://github.com/WordPress/gutenberg/pull/40025#discussion_r865410589 for more context.
20
24
 
21
25
  /**
22
26
  * Shared reference to an empty object for cases where it is important to avoid
@@ -142,9 +146,7 @@ export function getEntity(state, kind, name) {
142
146
  */
143
147
 
144
148
  export function getEntityConfig(state, kind, name) {
145
- var _state$entities$confi;
146
-
147
- return (_state$entities$confi = state.entities.config) === null || _state$entities$confi === void 0 ? void 0 : _state$entities$confi.find(config => config.kind === kind && config.name === name);
149
+ return state.entities.config?.find(config => config.kind === kind && config.name === name);
148
150
  }
149
151
  /**
150
152
  * GetEntityRecord is declared as a *callable interface* with
@@ -186,28 +188,26 @@ export function getEntityConfig(state, kind, name) {
186
188
  * @return Record.
187
189
  */
188
190
  export const getEntityRecord = createSelector((state, kind, name, key, query) => {
189
- var _state$entities$recor, _state$entities$recor2, _state$entities$recor3, _query$context, _queriedState$items$c;
191
+ var _query$context;
190
192
 
191
- const queriedState = (_state$entities$recor = state.entities.records) === null || _state$entities$recor === void 0 ? void 0 : (_state$entities$recor2 = _state$entities$recor[kind]) === null || _state$entities$recor2 === void 0 ? void 0 : (_state$entities$recor3 = _state$entities$recor2[name]) === null || _state$entities$recor3 === void 0 ? void 0 : _state$entities$recor3.queriedData;
193
+ const queriedState = state.entities.records?.[kind]?.[name]?.queriedData;
192
194
 
193
195
  if (!queriedState) {
194
196
  return undefined;
195
197
  }
196
198
 
197
- const context = (_query$context = query === null || query === void 0 ? void 0 : query.context) !== null && _query$context !== void 0 ? _query$context : 'default';
199
+ const context = (_query$context = query?.context) !== null && _query$context !== void 0 ? _query$context : 'default';
198
200
 
199
201
  if (query === undefined) {
200
- var _queriedState$itemIsC;
201
-
202
202
  // If expecting a complete item, validate that completeness.
203
- if (!((_queriedState$itemIsC = queriedState.itemIsComplete[context]) !== null && _queriedState$itemIsC !== void 0 && _queriedState$itemIsC[key])) {
203
+ if (!queriedState.itemIsComplete[context]?.[key]) {
204
204
  return undefined;
205
205
  }
206
206
 
207
207
  return queriedState.items[context][key];
208
208
  }
209
209
 
210
- const item = (_queriedState$items$c = queriedState.items[context]) === null || _queriedState$items$c === void 0 ? void 0 : _queriedState$items$c[key];
210
+ const item = queriedState.items[context]?.[key];
211
211
 
212
212
  if (item && query._fields) {
213
213
  var _getNormalizedCommaSe;
@@ -229,10 +229,10 @@ export const getEntityRecord = createSelector((state, kind, name, key, query) =>
229
229
 
230
230
  return item;
231
231
  }, (state, kind, name, recordId, query) => {
232
- var _query$context2, _state$entities$recor4, _state$entities$recor5, _state$entities$recor6, _state$entities$recor7, _state$entities$recor8, _state$entities$recor9, _state$entities$recor10, _state$entities$recor11, _state$entities$recor12, _state$entities$recor13;
232
+ var _query$context2;
233
233
 
234
- const context = (_query$context2 = query === null || query === void 0 ? void 0 : query.context) !== null && _query$context2 !== void 0 ? _query$context2 : 'default';
235
- return [(_state$entities$recor4 = state.entities.records) === null || _state$entities$recor4 === void 0 ? void 0 : (_state$entities$recor5 = _state$entities$recor4[kind]) === null || _state$entities$recor5 === void 0 ? void 0 : (_state$entities$recor6 = _state$entities$recor5[name]) === null || _state$entities$recor6 === void 0 ? void 0 : (_state$entities$recor7 = _state$entities$recor6.queriedData) === null || _state$entities$recor7 === void 0 ? void 0 : (_state$entities$recor8 = _state$entities$recor7.items[context]) === null || _state$entities$recor8 === void 0 ? void 0 : _state$entities$recor8[recordId], (_state$entities$recor9 = state.entities.records) === null || _state$entities$recor9 === void 0 ? void 0 : (_state$entities$recor10 = _state$entities$recor9[kind]) === null || _state$entities$recor10 === void 0 ? void 0 : (_state$entities$recor11 = _state$entities$recor10[name]) === null || _state$entities$recor11 === void 0 ? void 0 : (_state$entities$recor12 = _state$entities$recor11.queriedData) === null || _state$entities$recor12 === void 0 ? void 0 : (_state$entities$recor13 = _state$entities$recor12.itemIsComplete[context]) === null || _state$entities$recor13 === void 0 ? void 0 : _state$entities$recor13[recordId]];
234
+ const context = (_query$context2 = query?.context) !== null && _query$context2 !== void 0 ? _query$context2 : 'default';
235
+ return [state.entities.records?.[kind]?.[name]?.queriedData?.items[context]?.[recordId], state.entities.records?.[kind]?.[name]?.queriedData?.itemIsComplete[context]?.[recordId]];
236
236
  });
237
237
  /**
238
238
  * Returns the Entity's record object by key. Doesn't trigger a resolver nor requests the entity records from the API if the entity record isn't available in the local state.
@@ -264,12 +264,12 @@ export const getRawEntityRecord = createSelector((state, kind, name, key) => {
264
264
  const record = getEntityRecord(state, kind, name, key);
265
265
  return record && Object.keys(record).reduce((accumulator, _key) => {
266
266
  if (isRawAttribute(getEntityConfig(state, kind, name), _key)) {
267
- var _record$_key$raw, _record$_key;
267
+ var _record$_key$raw;
268
268
 
269
269
  // Because edits are the "raw" attribute values,
270
270
  // we return those from record selectors to make rendering,
271
271
  // comparisons, and joins with edits easier.
272
- accumulator[_key] = (_record$_key$raw = (_record$_key = record[_key]) === null || _record$_key === void 0 ? void 0 : _record$_key.raw) !== null && _record$_key$raw !== void 0 ? _record$_key$raw : record[_key];
272
+ accumulator[_key] = (_record$_key$raw = record[_key]?.raw) !== null && _record$_key$raw !== void 0 ? _record$_key$raw : record[_key];
273
273
  } else {
274
274
  accumulator[_key] = record[_key];
275
275
  }
@@ -277,10 +277,10 @@ export const getRawEntityRecord = createSelector((state, kind, name, key) => {
277
277
  return accumulator;
278
278
  }, {});
279
279
  }, (state, kind, name, recordId, query) => {
280
- var _query$context3, _state$entities$recor14, _state$entities$recor15, _state$entities$recor16, _state$entities$recor17, _state$entities$recor18, _state$entities$recor19, _state$entities$recor20, _state$entities$recor21, _state$entities$recor22, _state$entities$recor23;
280
+ var _query$context3;
281
281
 
282
- const context = (_query$context3 = query === null || query === void 0 ? void 0 : query.context) !== null && _query$context3 !== void 0 ? _query$context3 : 'default';
283
- return [state.entities.config, (_state$entities$recor14 = state.entities.records) === null || _state$entities$recor14 === void 0 ? void 0 : (_state$entities$recor15 = _state$entities$recor14[kind]) === null || _state$entities$recor15 === void 0 ? void 0 : (_state$entities$recor16 = _state$entities$recor15[name]) === null || _state$entities$recor16 === void 0 ? void 0 : (_state$entities$recor17 = _state$entities$recor16.queriedData) === null || _state$entities$recor17 === void 0 ? void 0 : (_state$entities$recor18 = _state$entities$recor17.items[context]) === null || _state$entities$recor18 === void 0 ? void 0 : _state$entities$recor18[recordId], (_state$entities$recor19 = state.entities.records) === null || _state$entities$recor19 === void 0 ? void 0 : (_state$entities$recor20 = _state$entities$recor19[kind]) === null || _state$entities$recor20 === void 0 ? void 0 : (_state$entities$recor21 = _state$entities$recor20[name]) === null || _state$entities$recor21 === void 0 ? void 0 : (_state$entities$recor22 = _state$entities$recor21.queriedData) === null || _state$entities$recor22 === void 0 ? void 0 : (_state$entities$recor23 = _state$entities$recor22.itemIsComplete[context]) === null || _state$entities$recor23 === void 0 ? void 0 : _state$entities$recor23[recordId]];
282
+ const context = (_query$context3 = query?.context) !== null && _query$context3 !== void 0 ? _query$context3 : 'default';
283
+ return [state.entities.config, state.entities.records?.[kind]?.[name]?.queriedData?.items[context]?.[recordId], state.entities.records?.[kind]?.[name]?.queriedData?.itemIsComplete[context]?.[recordId]];
284
284
  });
285
285
  /**
286
286
  * Returns true if records have been received for the given set of parameters,
@@ -318,11 +318,9 @@ export function hasEntityRecords(state, kind, name, query) {
318
318
  * @return Records.
319
319
  */
320
320
  export const getEntityRecords = (state, kind, name, query) => {
321
- var _state$entities$recor24, _state$entities$recor25, _state$entities$recor26;
322
-
323
321
  // Queried data state is prepopulated for all known entities. If this is not
324
322
  // assigned for the given parameters, then it is known to not exist.
325
- const queriedState = (_state$entities$recor24 = state.entities.records) === null || _state$entities$recor24 === void 0 ? void 0 : (_state$entities$recor25 = _state$entities$recor24[kind]) === null || _state$entities$recor25 === void 0 ? void 0 : (_state$entities$recor26 = _state$entities$recor25[name]) === null || _state$entities$recor26 === void 0 ? void 0 : _state$entities$recor26.queriedData;
323
+ const queriedState = state.entities.records?.[kind]?.[name]?.queriedData;
326
324
 
327
325
  if (!queriedState) {
328
326
  return null;
@@ -354,14 +352,12 @@ export const __experimentalGetDirtyEntityRecords = createSelector(state => {
354
352
  if (primaryKeys.length) {
355
353
  const entityConfig = getEntityConfig(state, kind, name);
356
354
  primaryKeys.forEach(primaryKey => {
357
- var _entityConfig$getTitl;
358
-
359
355
  const entityRecord = getEditedEntityRecord(state, kind, name, primaryKey);
360
356
  dirtyRecords.push({
361
357
  // We avoid using primaryKey because it's transformed into a string
362
358
  // when it's used as an object key.
363
359
  key: entityRecord ? entityRecord[entityConfig.key || DEFAULT_ENTITY_KEY] : undefined,
364
- title: (entityConfig === null || entityConfig === void 0 ? void 0 : (_entityConfig$getTitl = entityConfig.getTitle) === null || _entityConfig$getTitl === void 0 ? void 0 : _entityConfig$getTitl.call(entityConfig, entityRecord)) || '',
360
+ title: entityConfig?.getTitle?.(entityRecord) || '',
365
361
  name,
366
362
  kind
367
363
  });
@@ -393,14 +389,12 @@ export const __experimentalGetEntitiesBeingSaved = createSelector(state => {
393
389
  if (primaryKeys.length) {
394
390
  const entityConfig = getEntityConfig(state, kind, name);
395
391
  primaryKeys.forEach(primaryKey => {
396
- var _entityConfig$getTitl2;
397
-
398
392
  const entityRecord = getEditedEntityRecord(state, kind, name, primaryKey);
399
393
  recordsBeingSaved.push({
400
394
  // We avoid using primaryKey because it's transformed into a string
401
395
  // when it's used as an object key.
402
396
  key: entityRecord ? entityRecord[entityConfig.key || DEFAULT_ENTITY_KEY] : undefined,
403
- title: (entityConfig === null || entityConfig === void 0 ? void 0 : (_entityConfig$getTitl2 = entityConfig.getTitle) === null || _entityConfig$getTitl2 === void 0 ? void 0 : _entityConfig$getTitl2.call(entityConfig, entityRecord)) || '',
397
+ title: entityConfig?.getTitle?.(entityRecord) || '',
404
398
  name,
405
399
  kind
406
400
  });
@@ -422,9 +416,7 @@ export const __experimentalGetEntitiesBeingSaved = createSelector(state => {
422
416
  */
423
417
 
424
418
  export function getEntityRecordEdits(state, kind, name, recordId) {
425
- var _state$entities$recor27, _state$entities$recor28, _state$entities$recor29, _state$entities$recor30;
426
-
427
- return (_state$entities$recor27 = state.entities.records) === null || _state$entities$recor27 === void 0 ? void 0 : (_state$entities$recor28 = _state$entities$recor27[kind]) === null || _state$entities$recor28 === void 0 ? void 0 : (_state$entities$recor29 = _state$entities$recor28[name]) === null || _state$entities$recor29 === void 0 ? void 0 : (_state$entities$recor30 = _state$entities$recor29.edits) === null || _state$entities$recor30 === void 0 ? void 0 : _state$entities$recor30[recordId];
419
+ return state.entities.records?.[kind]?.[name]?.edits?.[recordId];
428
420
  }
429
421
  /**
430
422
  * Returns the specified entity record's non transient edits.
@@ -458,11 +450,7 @@ export const getEntityRecordNonTransientEdits = createSelector((state, kind, nam
458
450
 
459
451
  return acc;
460
452
  }, {});
461
- }, (state, kind, name, recordId) => {
462
- var _state$entities$recor31, _state$entities$recor32, _state$entities$recor33, _state$entities$recor34;
463
-
464
- return [state.entities.config, (_state$entities$recor31 = state.entities.records) === null || _state$entities$recor31 === void 0 ? void 0 : (_state$entities$recor32 = _state$entities$recor31[kind]) === null || _state$entities$recor32 === void 0 ? void 0 : (_state$entities$recor33 = _state$entities$recor32[name]) === null || _state$entities$recor33 === void 0 ? void 0 : (_state$entities$recor34 = _state$entities$recor33.edits) === null || _state$entities$recor34 === void 0 ? void 0 : _state$entities$recor34[recordId]];
465
- });
453
+ }, (state, kind, name, recordId) => [state.entities.config, state.entities.records?.[kind]?.[name]?.edits?.[recordId]]);
466
454
  /**
467
455
  * Returns true if the specified entity record has edits,
468
456
  * and false otherwise.
@@ -492,10 +480,10 @@ export function hasEditsForEntityRecord(state, kind, name, recordId) {
492
480
  export const getEditedEntityRecord = createSelector((state, kind, name, recordId) => ({ ...getRawEntityRecord(state, kind, name, recordId),
493
481
  ...getEntityRecordEdits(state, kind, name, recordId)
494
482
  }), (state, kind, name, recordId, query) => {
495
- var _query$context4, _state$entities$recor35, _state$entities$recor36, _state$entities$recor37, _state$entities$recor38, _state$entities$recor39, _state$entities$recor40, _state$entities$recor41, _state$entities$recor42, _state$entities$recor43, _state$entities$recor44, _state$entities$recor45, _state$entities$recor46;
483
+ var _query$context4;
496
484
 
497
- const context = (_query$context4 = query === null || query === void 0 ? void 0 : query.context) !== null && _query$context4 !== void 0 ? _query$context4 : 'default';
498
- return [state.entities.config, (_state$entities$recor35 = state.entities.records) === null || _state$entities$recor35 === void 0 ? void 0 : (_state$entities$recor36 = _state$entities$recor35[kind]) === null || _state$entities$recor36 === void 0 ? void 0 : (_state$entities$recor37 = _state$entities$recor36[name]) === null || _state$entities$recor37 === void 0 ? void 0 : (_state$entities$recor38 = _state$entities$recor37.queriedData.items[context]) === null || _state$entities$recor38 === void 0 ? void 0 : _state$entities$recor38[recordId], (_state$entities$recor39 = state.entities.records) === null || _state$entities$recor39 === void 0 ? void 0 : (_state$entities$recor40 = _state$entities$recor39[kind]) === null || _state$entities$recor40 === void 0 ? void 0 : (_state$entities$recor41 = _state$entities$recor40[name]) === null || _state$entities$recor41 === void 0 ? void 0 : (_state$entities$recor42 = _state$entities$recor41.queriedData.itemIsComplete[context]) === null || _state$entities$recor42 === void 0 ? void 0 : _state$entities$recor42[recordId], (_state$entities$recor43 = state.entities.records) === null || _state$entities$recor43 === void 0 ? void 0 : (_state$entities$recor44 = _state$entities$recor43[kind]) === null || _state$entities$recor44 === void 0 ? void 0 : (_state$entities$recor45 = _state$entities$recor44[name]) === null || _state$entities$recor45 === void 0 ? void 0 : (_state$entities$recor46 = _state$entities$recor45.edits) === null || _state$entities$recor46 === void 0 ? void 0 : _state$entities$recor46[recordId]];
485
+ const context = (_query$context4 = query?.context) !== null && _query$context4 !== void 0 ? _query$context4 : 'default';
486
+ return [state.entities.config, state.entities.records?.[kind]?.[name]?.queriedData.items[context]?.[recordId], state.entities.records?.[kind]?.[name]?.queriedData.itemIsComplete[context]?.[recordId], state.entities.records?.[kind]?.[name]?.edits?.[recordId]];
499
487
  });
500
488
  /**
501
489
  * Returns true if the specified entity record is autosaving, and false otherwise.
@@ -509,12 +497,12 @@ export const getEditedEntityRecord = createSelector((state, kind, name, recordId
509
497
  */
510
498
 
511
499
  export function isAutosavingEntityRecord(state, kind, name, recordId) {
512
- var _state$entities$recor47, _state$entities$recor48, _state$entities$recor49, _state$entities$recor50, _state$entities$recor51;
500
+ var _state$entities$recor;
513
501
 
514
502
  const {
515
503
  pending,
516
504
  isAutosave
517
- } = (_state$entities$recor47 = (_state$entities$recor48 = state.entities.records) === null || _state$entities$recor48 === void 0 ? void 0 : (_state$entities$recor49 = _state$entities$recor48[kind]) === null || _state$entities$recor49 === void 0 ? void 0 : (_state$entities$recor50 = _state$entities$recor49[name]) === null || _state$entities$recor50 === void 0 ? void 0 : (_state$entities$recor51 = _state$entities$recor50.saving) === null || _state$entities$recor51 === void 0 ? void 0 : _state$entities$recor51[recordId]) !== null && _state$entities$recor47 !== void 0 ? _state$entities$recor47 : {};
505
+ } = (_state$entities$recor = state.entities.records?.[kind]?.[name]?.saving?.[recordId]) !== null && _state$entities$recor !== void 0 ? _state$entities$recor : {};
518
506
  return Boolean(pending && isAutosave);
519
507
  }
520
508
  /**
@@ -529,9 +517,9 @@ export function isAutosavingEntityRecord(state, kind, name, recordId) {
529
517
  */
530
518
 
531
519
  export function isSavingEntityRecord(state, kind, name, recordId) {
532
- var _state$entities$recor52, _state$entities$recor53, _state$entities$recor54, _state$entities$recor55, _state$entities$recor56, _state$entities$recor57;
520
+ var _state$entities$recor2;
533
521
 
534
- return (_state$entities$recor52 = (_state$entities$recor53 = state.entities.records) === null || _state$entities$recor53 === void 0 ? void 0 : (_state$entities$recor54 = _state$entities$recor53[kind]) === null || _state$entities$recor54 === void 0 ? void 0 : (_state$entities$recor55 = _state$entities$recor54[name]) === null || _state$entities$recor55 === void 0 ? void 0 : (_state$entities$recor56 = _state$entities$recor55.saving) === null || _state$entities$recor56 === void 0 ? void 0 : (_state$entities$recor57 = _state$entities$recor56[recordId]) === null || _state$entities$recor57 === void 0 ? void 0 : _state$entities$recor57.pending) !== null && _state$entities$recor52 !== void 0 ? _state$entities$recor52 : false;
522
+ return (_state$entities$recor2 = state.entities.records?.[kind]?.[name]?.saving?.[recordId]?.pending) !== null && _state$entities$recor2 !== void 0 ? _state$entities$recor2 : false;
535
523
  }
536
524
  /**
537
525
  * Returns true if the specified entity record is deleting, and false otherwise.
@@ -545,9 +533,9 @@ export function isSavingEntityRecord(state, kind, name, recordId) {
545
533
  */
546
534
 
547
535
  export function isDeletingEntityRecord(state, kind, name, recordId) {
548
- var _state$entities$recor58, _state$entities$recor59, _state$entities$recor60, _state$entities$recor61, _state$entities$recor62, _state$entities$recor63;
536
+ var _state$entities$recor3;
549
537
 
550
- return (_state$entities$recor58 = (_state$entities$recor59 = state.entities.records) === null || _state$entities$recor59 === void 0 ? void 0 : (_state$entities$recor60 = _state$entities$recor59[kind]) === null || _state$entities$recor60 === void 0 ? void 0 : (_state$entities$recor61 = _state$entities$recor60[name]) === null || _state$entities$recor61 === void 0 ? void 0 : (_state$entities$recor62 = _state$entities$recor61.deleting) === null || _state$entities$recor62 === void 0 ? void 0 : (_state$entities$recor63 = _state$entities$recor62[recordId]) === null || _state$entities$recor63 === void 0 ? void 0 : _state$entities$recor63.pending) !== null && _state$entities$recor58 !== void 0 ? _state$entities$recor58 : false;
538
+ return (_state$entities$recor3 = state.entities.records?.[kind]?.[name]?.deleting?.[recordId]?.pending) !== null && _state$entities$recor3 !== void 0 ? _state$entities$recor3 : false;
551
539
  }
552
540
  /**
553
541
  * Returns the specified entity record's last save error.
@@ -561,9 +549,7 @@ export function isDeletingEntityRecord(state, kind, name, recordId) {
561
549
  */
562
550
 
563
551
  export function getLastEntitySaveError(state, kind, name, recordId) {
564
- var _state$entities$recor64, _state$entities$recor65, _state$entities$recor66, _state$entities$recor67, _state$entities$recor68;
565
-
566
- return (_state$entities$recor64 = state.entities.records) === null || _state$entities$recor64 === void 0 ? void 0 : (_state$entities$recor65 = _state$entities$recor64[kind]) === null || _state$entities$recor65 === void 0 ? void 0 : (_state$entities$recor66 = _state$entities$recor65[name]) === null || _state$entities$recor66 === void 0 ? void 0 : (_state$entities$recor67 = _state$entities$recor66.saving) === null || _state$entities$recor67 === void 0 ? void 0 : (_state$entities$recor68 = _state$entities$recor67[recordId]) === null || _state$entities$recor68 === void 0 ? void 0 : _state$entities$recor68.error;
552
+ return state.entities.records?.[kind]?.[name]?.saving?.[recordId]?.error;
567
553
  }
568
554
  /**
569
555
  * Returns the specified entity record's last delete error.
@@ -577,9 +563,7 @@ export function getLastEntitySaveError(state, kind, name, recordId) {
577
563
  */
578
564
 
579
565
  export function getLastEntityDeleteError(state, kind, name, recordId) {
580
- var _state$entities$recor69, _state$entities$recor70, _state$entities$recor71, _state$entities$recor72, _state$entities$recor73;
581
-
582
- return (_state$entities$recor69 = state.entities.records) === null || _state$entities$recor69 === void 0 ? void 0 : (_state$entities$recor70 = _state$entities$recor69[kind]) === null || _state$entities$recor70 === void 0 ? void 0 : (_state$entities$recor71 = _state$entities$recor70[name]) === null || _state$entities$recor71 === void 0 ? void 0 : (_state$entities$recor72 = _state$entities$recor71.deleting) === null || _state$entities$recor72 === void 0 ? void 0 : (_state$entities$recor73 = _state$entities$recor72[recordId]) === null || _state$entities$recor73 === void 0 ? void 0 : _state$entities$recor73.error;
566
+ return state.entities.records?.[kind]?.[name]?.deleting?.[recordId]?.error;
583
567
  }
584
568
  /**
585
569
  * Returns the current undo offset for the
@@ -600,26 +584,36 @@ function getCurrentUndoOffset(state) {
600
584
  * Returns the previous edit from the current undo offset
601
585
  * for the entity records edits history, if any.
602
586
  *
603
- * @param state State tree.
587
+ * @deprecated since 6.3
588
+ *
589
+ * @param state State tree.
604
590
  *
605
591
  * @return The edit.
606
592
  */
607
593
 
608
594
 
609
595
  export function getUndoEdit(state) {
610
- return state.undo[state.undo.length - 2 + getCurrentUndoOffset(state)];
596
+ deprecated("select( 'core' ).getUndoEdit()", {
597
+ since: '6.3'
598
+ });
599
+ return state.undo.list[state.undo.list.length - 2 + getCurrentUndoOffset(state)]?.[0];
611
600
  }
612
601
  /**
613
602
  * Returns the next edit from the current undo offset
614
603
  * for the entity records edits history, if any.
615
604
  *
616
- * @param state State tree.
605
+ * @deprecated since 6.3
606
+ *
607
+ * @param state State tree.
617
608
  *
618
609
  * @return The edit.
619
610
  */
620
611
 
621
612
  export function getRedoEdit(state) {
622
- return state.undo[state.undo.length + getCurrentUndoOffset(state)];
613
+ deprecated("select( 'core' ).getRedoEdit()", {
614
+ since: '6.3'
615
+ });
616
+ return state.undo.list[state.undo.list.length + getCurrentUndoOffset(state)]?.[0];
623
617
  }
624
618
  /**
625
619
  * Returns true if there is a previous edit from the current undo offset
@@ -631,7 +625,7 @@ export function getRedoEdit(state) {
631
625
  */
632
626
 
633
627
  export function hasUndo(state) {
634
- return Boolean(getUndoEdit(state));
628
+ return Boolean(getUndoEdits(state));
635
629
  }
636
630
  /**
637
631
  * Returns true if there is a next edit from the current undo offset
@@ -643,7 +637,7 @@ export function hasUndo(state) {
643
637
  */
644
638
 
645
639
  export function hasRedo(state) {
646
- return Boolean(getRedoEdit(state));
640
+ return Boolean(getRedoEdits(state));
647
641
  }
648
642
  /**
649
643
  * Return the current theme.
@@ -676,9 +670,9 @@ export function __experimentalGetCurrentGlobalStylesId(state) {
676
670
  */
677
671
 
678
672
  export function getThemeSupports(state) {
679
- var _getCurrentTheme$them, _getCurrentTheme;
673
+ var _getCurrentTheme$them;
680
674
 
681
- return (_getCurrentTheme$them = (_getCurrentTheme = getCurrentTheme(state)) === null || _getCurrentTheme === void 0 ? void 0 : _getCurrentTheme.theme_supports) !== null && _getCurrentTheme$them !== void 0 ? _getCurrentTheme$them : EMPTY_OBJECT;
675
+ return (_getCurrentTheme$them = getCurrentTheme(state)?.theme_supports) !== null && _getCurrentTheme$them !== void 0 ? _getCurrentTheme$them : EMPTY_OBJECT;
682
676
  }
683
677
  /**
684
678
  * Returns the embed preview for the given URL.
@@ -796,7 +790,7 @@ export function getAutosave(state, postType, postId, authorId) {
796
790
  }
797
791
 
798
792
  const autosaves = state.autosaves[postId];
799
- return autosaves === null || autosaves === void 0 ? void 0 : autosaves.find(autosave => autosave.author === authorId);
793
+ return autosaves?.find(autosave => autosave.author === authorId);
800
794
  }
801
795
  /**
802
796
  * Returns true if the REST request for autosaves has completed.
@@ -831,7 +825,7 @@ export const hasFetchedAutosaves = createRegistrySelector(select => (state, post
831
825
  */
832
826
 
833
827
  export const getReferenceByDistinctEdits = createSelector( // This unused state argument is listed here for the documentation generating tool (docgen).
834
- state => [], state => [state.undo.length, state.undo.offset, state.undo.flattenedUndo]);
828
+ state => [], state => [state.undo.list.length, state.undo.offset]);
835
829
  /**
836
830
  * Retrieve the frontend template used for a given link.
837
831
  *
@@ -846,7 +840,7 @@ export function __experimentalGetTemplateForLink(state, link) {
846
840
  'find-template': link
847
841
  });
848
842
 
849
- if (records !== null && records !== void 0 && records.length) {
843
+ if (records?.length) {
850
844
  return getEditedEntityRecord(state, 'postType', 'wp_template', records[0].id);
851
845
  }
852
846