@wordpress/core-data 7.13.0 → 7.13.1-next.cd6172eb0.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 (33) hide show
  1. package/README.md +1 -1
  2. package/build/batch/create-batch.js +0 -1
  3. package/build/batch/create-batch.js.map +1 -1
  4. package/build/fetch/__experimental-fetch-link-suggestions.js +10 -2
  5. package/build/fetch/__experimental-fetch-link-suggestions.js.map +1 -1
  6. package/build/private-selectors.js +1 -3
  7. package/build/private-selectors.js.map +1 -1
  8. package/build/resolvers.js +0 -1
  9. package/build/resolvers.js.map +1 -1
  10. package/build/selectors.js +1 -1
  11. package/build/selectors.js.map +1 -1
  12. package/build-module/batch/create-batch.js +0 -1
  13. package/build-module/batch/create-batch.js.map +1 -1
  14. package/build-module/fetch/__experimental-fetch-link-suggestions.js +10 -2
  15. package/build-module/fetch/__experimental-fetch-link-suggestions.js.map +1 -1
  16. package/build-module/private-selectors.js +1 -3
  17. package/build-module/private-selectors.js.map +1 -1
  18. package/build-module/resolvers.js +0 -1
  19. package/build-module/resolvers.js.map +1 -1
  20. package/build-module/selectors.js +1 -1
  21. package/build-module/selectors.js.map +1 -1
  22. package/build-types/fetch/__experimental-fetch-link-suggestions.d.ts.map +1 -1
  23. package/build-types/lock-unlock.d.ts +1 -1
  24. package/build-types/lock-unlock.d.ts.map +1 -1
  25. package/build-types/private-selectors.d.ts.map +1 -1
  26. package/build-types/selectors.d.ts +3 -3
  27. package/build-types/selectors.d.ts.map +1 -1
  28. package/package.json +18 -18
  29. package/src/fetch/__experimental-fetch-link-suggestions.ts +21 -4
  30. package/src/fetch/test/__experimental-fetch-link-suggestions.js +37 -0
  31. package/src/private-selectors.ts +0 -1
  32. package/src/selectors.ts +4 -4
  33. package/tsconfig.tsbuildinfo +1 -1
package/README.md CHANGED
@@ -581,7 +581,7 @@ _Parameters_
581
581
  - _state_ `State`: State tree
582
582
  - _kind_ `string`: Entity kind.
583
583
  - _name_ `string`: Entity name.
584
- - _key_ `EntityRecordKey`: Record's key
584
+ - _key_ `EntityRecordKey`: Optional record's key. If requesting a global record (e.g. site settings), the key can be omitted. If requesting a specific item, the key must always be included.
585
585
  - _query_ `GetRecordsHttpQuery`: Optional query. If requesting specific fields, fields must always include the ID. For valid query parameters see the [Reference](https://developer.wordpress.org/rest-api/reference/) in the REST API Handbook and select the entity kind. Then see the arguments available "Retrieve a [Entity kind]".
586
586
 
587
587
  _Returns_
@@ -1,4 +1,3 @@
1
- /* wp:polyfill */
2
1
  "use strict";
3
2
 
4
3
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
@@ -1 +1 @@
1
- {"version":3,"names":["_defaultProcessor","_interopRequireDefault","require","createBatch","processor","defaultProcessor","lastId","queue","pending","ObservableSet","add","inputOrThunk","id","input","Promise","resolve","reject","push","delete","finally","run","size","unsubscribe","subscribe","undefined","results","map","length","Error","error","isSuccess","forEach","result","key","queueItem","_result$output","output","constructor","args","set","Set","subscribers","value","subscriber"],"sources":["@wordpress/core-data/src/batch/create-batch.js"],"sourcesContent":["/**\n * Internal dependencies\n */\nimport defaultProcessor from './default-processor';\n\n/**\n * Creates a batch, which can be used to combine multiple API requests into one\n * API request using the WordPress batch processing API (/v1/batch).\n *\n * ```\n * const batch = createBatch();\n * const dunePromise = batch.add( {\n * path: '/v1/books',\n * method: 'POST',\n * data: { title: 'Dune' }\n * } );\n * const lotrPromise = batch.add( {\n * path: '/v1/books',\n * method: 'POST',\n * data: { title: 'Lord of the Rings' }\n * } );\n * const isSuccess = await batch.run(); // Sends one POST to /v1/batch.\n * if ( isSuccess ) {\n * console.log(\n * 'Saved two books:',\n * await dunePromise,\n * await lotrPromise\n * );\n * }\n * ```\n *\n * @param {Function} [processor] Processor function. Can be used to replace the\n * default functionality which is to send an API\n * request to /v1/batch. Is given an array of\n * inputs and must return a promise that\n * resolves to an array of objects containing\n * either `output` or `error`.\n */\nexport default function createBatch( processor = defaultProcessor ) {\n\tlet lastId = 0;\n\t/** @type {Array<{ input: any; resolve: ( value: any ) => void; reject: ( error: any ) => void }>} */\n\tlet queue = [];\n\tconst pending = new ObservableSet();\n\n\treturn {\n\t\t/**\n\t\t * Adds an input to the batch and returns a promise that is resolved or\n\t\t * rejected when the input is processed by `batch.run()`.\n\t\t *\n\t\t * You may also pass a thunk which allows inputs to be added\n\t\t * asychronously.\n\t\t *\n\t\t * ```\n\t\t * // Both are allowed:\n\t\t * batch.add( { path: '/v1/books', ... } );\n\t\t * batch.add( ( add ) => add( { path: '/v1/books', ... } ) );\n\t\t * ```\n\t\t *\n\t\t * If a thunk is passed, `batch.run()` will pause until either:\n\t\t *\n\t\t * - The thunk calls its `add` argument, or;\n\t\t * - The thunk returns a promise and that promise resolves, or;\n\t\t * - The thunk returns a non-promise.\n\t\t *\n\t\t * @param {any|Function} inputOrThunk Input to add or thunk to execute.\n\t\t *\n\t\t * @return {Promise|any} If given an input, returns a promise that\n\t\t * is resolved or rejected when the batch is\n\t\t * processed. If given a thunk, returns the return\n\t\t * value of that thunk.\n\t\t */\n\t\tadd( inputOrThunk ) {\n\t\t\tconst id = ++lastId;\n\t\t\tpending.add( id );\n\n\t\t\tconst add = ( input ) =>\n\t\t\t\tnew Promise( ( resolve, reject ) => {\n\t\t\t\t\tqueue.push( {\n\t\t\t\t\t\tinput,\n\t\t\t\t\t\tresolve,\n\t\t\t\t\t\treject,\n\t\t\t\t\t} );\n\t\t\t\t\tpending.delete( id );\n\t\t\t\t} );\n\n\t\t\tif ( typeof inputOrThunk === 'function' ) {\n\t\t\t\treturn Promise.resolve( inputOrThunk( add ) ).finally( () => {\n\t\t\t\t\tpending.delete( id );\n\t\t\t\t} );\n\t\t\t}\n\n\t\t\treturn add( inputOrThunk );\n\t\t},\n\n\t\t/**\n\t\t * Runs the batch. This calls `batchProcessor` and resolves or rejects\n\t\t * all promises returned by `add()`.\n\t\t *\n\t\t * @return {Promise<boolean>} A promise that resolves to a boolean that is true\n\t\t * if the processor returned no errors.\n\t\t */\n\t\tasync run() {\n\t\t\tif ( pending.size ) {\n\t\t\t\tawait new Promise( ( resolve ) => {\n\t\t\t\t\tconst unsubscribe = pending.subscribe( () => {\n\t\t\t\t\t\tif ( ! pending.size ) {\n\t\t\t\t\t\t\tunsubscribe();\n\t\t\t\t\t\t\tresolve( undefined );\n\t\t\t\t\t\t}\n\t\t\t\t\t} );\n\t\t\t\t} );\n\t\t\t}\n\n\t\t\tlet results;\n\n\t\t\ttry {\n\t\t\t\tresults = await processor(\n\t\t\t\t\tqueue.map( ( { input } ) => input )\n\t\t\t\t);\n\n\t\t\t\tif ( results.length !== queue.length ) {\n\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\t'run: Array returned by processor must be same size as input array.'\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t} catch ( error ) {\n\t\t\t\tfor ( const { reject } of queue ) {\n\t\t\t\t\treject( error );\n\t\t\t\t}\n\n\t\t\t\tthrow error;\n\t\t\t}\n\n\t\t\tlet isSuccess = true;\n\n\t\t\tresults.forEach( ( result, key ) => {\n\t\t\t\tconst queueItem = queue[ key ];\n\n\t\t\t\tif ( result?.error ) {\n\t\t\t\t\tqueueItem?.reject( result.error );\n\t\t\t\t\tisSuccess = false;\n\t\t\t\t} else {\n\t\t\t\t\tqueueItem?.resolve( result?.output ?? result );\n\t\t\t\t}\n\t\t\t} );\n\n\t\t\tqueue = [];\n\n\t\t\treturn isSuccess;\n\t\t},\n\t};\n}\n\nclass ObservableSet {\n\tconstructor( ...args ) {\n\t\tthis.set = new Set( ...args );\n\t\tthis.subscribers = new Set();\n\t}\n\n\tget size() {\n\t\treturn this.set.size;\n\t}\n\n\tadd( value ) {\n\t\tthis.set.add( value );\n\t\tthis.subscribers.forEach( ( subscriber ) => subscriber() );\n\t\treturn this;\n\t}\n\n\tdelete( value ) {\n\t\tconst isSuccess = this.set.delete( value );\n\t\tthis.subscribers.forEach( ( subscriber ) => subscriber() );\n\t\treturn isSuccess;\n\t}\n\n\tsubscribe( subscriber ) {\n\t\tthis.subscribers.add( subscriber );\n\t\treturn () => {\n\t\t\tthis.subscribers.delete( subscriber );\n\t\t};\n\t}\n}\n"],"mappings":";;;;;;;;AAGA,IAAAA,iBAAA,GAAAC,sBAAA,CAAAC,OAAA;AAHA;AACA;AACA;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACe,SAASC,WAAWA,CAAEC,SAAS,GAAGC,yBAAgB,EAAG;EACnE,IAAIC,MAAM,GAAG,CAAC;EACd;EACA,IAAIC,KAAK,GAAG,EAAE;EACd,MAAMC,OAAO,GAAG,IAAIC,aAAa,CAAC,CAAC;EAEnC,OAAO;IACN;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;IACEC,GAAGA,CAAEC,YAAY,EAAG;MACnB,MAAMC,EAAE,GAAG,EAAEN,MAAM;MACnBE,OAAO,CAACE,GAAG,CAAEE,EAAG,CAAC;MAEjB,MAAMF,GAAG,GAAKG,KAAK,IAClB,IAAIC,OAAO,CAAE,CAAEC,OAAO,EAAEC,MAAM,KAAM;QACnCT,KAAK,CAACU,IAAI,CAAE;UACXJ,KAAK;UACLE,OAAO;UACPC;QACD,CAAE,CAAC;QACHR,OAAO,CAACU,MAAM,CAAEN,EAAG,CAAC;MACrB,CAAE,CAAC;MAEJ,IAAK,OAAOD,YAAY,KAAK,UAAU,EAAG;QACzC,OAAOG,OAAO,CAACC,OAAO,CAAEJ,YAAY,CAAED,GAAI,CAAE,CAAC,CAACS,OAAO,CAAE,MAAM;UAC5DX,OAAO,CAACU,MAAM,CAAEN,EAAG,CAAC;QACrB,CAAE,CAAC;MACJ;MAEA,OAAOF,GAAG,CAAEC,Y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AC;MAEHzB,KAAK,GAAG,EAAE;MAEV,OAAOuB,SAAS;IACjB;EACD,CAAC;AACF;AAEA,MAAMrB,aAAa,CAAC;EACnB4B,WAAWA,CAAE,GAAGC,IAAI,EAAG;IACtB,IAAI,CAACC,GAAG,GAAG,IAAIC,GAAG,CAAE,GAAGF,IAAK,CAAC;IAC7B,IAAI,CAACG,WAAW,GAAG,IAAID,GAAG,CAAC,CAAC;EAC7B;EAEA,IAAInB,IAAIA,CAAA,EAAG;IACV,OAAO,IAAI,CAACkB,GAAG,CAAClB,IAAI;EACrB;EAEAX,GAAGA,CAAEgC,KAAK,EAAG;IACZ,IAAI,CAACH,GAAG,CAAC7B,GAAG,CAAEgC,KAAM,CAAC;IACrB,IAAI,CAACD,WAAW,CAACV,OAAO,CAAIY,UAAU,IAAMA,UAAU,CAAC,CAAE,CAAC;IAC1D,OAAO,IAAI;EACZ;EAEAzB,MAAMA,CAAEwB,KAAK,EAAG;IACf,MAAMZ,SAAS,GAAG,IAAI,CAACS,GAAG,CAACrB,MAAM,CAAEwB,KAAM,CAAC;IAC1C,IAAI,CAACD,WAAW,CAACV,OAAO,CAAIY,UAAU,IAAMA,UAAU,CAAC,CAAE,CAAC;IAC1D,OAAOb,SAAS;EACjB;EAEAP,SAASA,CAAEoB,UAAU,EAAG;IACvB,IAAI,CAACF,WAAW,CAAC/B,GAAG,CAAEiC,UAAW,CAAC;IAClC,OAAO,MAAM;MACZ,IAAI,CAACF,WAAW,CAACvB,MAAM,CAAEyB,UAAW,CAAC;IACtC,CAAC;EACF;AACD","ignoreList":[]}
1
+ {"version":3,"names":["_defaultProcessor","_interopRequireDefault","require","createBatch","processor","defaultProcessor","lastId","queue","pending","ObservableSet","add","inputOrThunk","id","input","Promise","resolve","reject","push","delete","finally","run","size","unsubscribe","subscribe","undefined","results","map","length","Error","error","isSuccess","forEach","result","key","queueItem","_result$output","output","constructor","args","set","Set","subscribers","value","subscriber"],"sources":["@wordpress/core-data/src/batch/create-batch.js"],"sourcesContent":["/**\n * Internal dependencies\n */\nimport defaultProcessor from './default-processor';\n\n/**\n * Creates a batch, which can be used to combine multiple API requests into one\n * API request using the WordPress batch processing API (/v1/batch).\n *\n * ```\n * const batch = createBatch();\n * const dunePromise = batch.add( {\n * path: '/v1/books',\n * method: 'POST',\n * data: { title: 'Dune' }\n * } );\n * const lotrPromise = batch.add( {\n * path: '/v1/books',\n * method: 'POST',\n * data: { title: 'Lord of the Rings' }\n * } );\n * const isSuccess = await batch.run(); // Sends one POST to /v1/batch.\n * if ( isSuccess ) {\n * console.log(\n * 'Saved two books:',\n * await dunePromise,\n * await lotrPromise\n * );\n * }\n * ```\n *\n * @param {Function} [processor] Processor function. Can be used to replace the\n * default functionality which is to send an API\n * request to /v1/batch. Is given an array of\n * inputs and must return a promise that\n * resolves to an array of objects containing\n * either `output` or `error`.\n */\nexport default function createBatch( processor = defaultProcessor ) {\n\tlet lastId = 0;\n\t/** @type {Array<{ input: any; resolve: ( value: any ) => void; reject: ( error: any ) => void }>} */\n\tlet queue = [];\n\tconst pending = new ObservableSet();\n\n\treturn {\n\t\t/**\n\t\t * Adds an input to the batch and returns a promise that is resolved or\n\t\t * rejected when the input is processed by `batch.run()`.\n\t\t *\n\t\t * You may also pass a thunk which allows inputs to be added\n\t\t * asychronously.\n\t\t *\n\t\t * ```\n\t\t * // Both are allowed:\n\t\t * batch.add( { path: '/v1/books', ... } );\n\t\t * batch.add( ( add ) => add( { path: '/v1/books', ... } ) );\n\t\t * ```\n\t\t *\n\t\t * If a thunk is passed, `batch.run()` will pause until either:\n\t\t *\n\t\t * - The thunk calls its `add` argument, or;\n\t\t * - The thunk returns a promise and that promise resolves, or;\n\t\t * - The thunk returns a non-promise.\n\t\t *\n\t\t * @param {any|Function} inputOrThunk Input to add or thunk to execute.\n\t\t *\n\t\t * @return {Promise|any} If given an input, returns a promise that\n\t\t * is resolved or rejected when the batch is\n\t\t * processed. If given a thunk, returns the return\n\t\t * value of that thunk.\n\t\t */\n\t\tadd( inputOrThunk ) {\n\t\t\tconst id = ++lastId;\n\t\t\tpending.add( id );\n\n\t\t\tconst add = ( input ) =>\n\t\t\t\tnew Promise( ( resolve, reject ) => {\n\t\t\t\t\tqueue.push( {\n\t\t\t\t\t\tinput,\n\t\t\t\t\t\tresolve,\n\t\t\t\t\t\treject,\n\t\t\t\t\t} );\n\t\t\t\t\tpending.delete( id );\n\t\t\t\t} );\n\n\t\t\tif ( typeof inputOrThunk === 'function' ) {\n\t\t\t\treturn Promise.resolve( inputOrThunk( add ) ).finally( () => {\n\t\t\t\t\tpending.delete( id );\n\t\t\t\t} );\n\t\t\t}\n\n\t\t\treturn add( inputOrThunk );\n\t\t},\n\n\t\t/**\n\t\t * Runs the batch. This calls `batchProcessor` and resolves or rejects\n\t\t * all promises returned by `add()`.\n\t\t *\n\t\t * @return {Promise<boolean>} A promise that resolves to a boolean that is true\n\t\t * if the processor returned no errors.\n\t\t */\n\t\tasync run() {\n\t\t\tif ( pending.size ) {\n\t\t\t\tawait new Promise( ( resolve ) => {\n\t\t\t\t\tconst unsubscribe = pending.subscribe( () => {\n\t\t\t\t\t\tif ( ! pending.size ) {\n\t\t\t\t\t\t\tunsubscribe();\n\t\t\t\t\t\t\tresolve( undefined );\n\t\t\t\t\t\t}\n\t\t\t\t\t} );\n\t\t\t\t} );\n\t\t\t}\n\n\t\t\tlet results;\n\n\t\t\ttry {\n\t\t\t\tresults = await processor(\n\t\t\t\t\tqueue.map( ( { input } ) => input )\n\t\t\t\t);\n\n\t\t\t\tif ( results.length !== queue.length ) {\n\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\t'run: Array returned by processor must be same size as input array.'\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t} catch ( error ) {\n\t\t\t\tfor ( const { reject } of queue ) {\n\t\t\t\t\treject( error );\n\t\t\t\t}\n\n\t\t\t\tthrow error;\n\t\t\t}\n\n\t\t\tlet isSuccess = true;\n\n\t\t\tresults.forEach( ( result, key ) => {\n\t\t\t\tconst queueItem = queue[ key ];\n\n\t\t\t\tif ( result?.error ) {\n\t\t\t\t\tqueueItem?.reject( result.error );\n\t\t\t\t\tisSuccess = false;\n\t\t\t\t} else {\n\t\t\t\t\tqueueItem?.resolve( result?.output ?? result );\n\t\t\t\t}\n\t\t\t} );\n\n\t\t\tqueue = [];\n\n\t\t\treturn isSuccess;\n\t\t},\n\t};\n}\n\nclass ObservableSet {\n\tconstructor( ...args ) {\n\t\tthis.set = new Set( ...args );\n\t\tthis.subscribers = new Set();\n\t}\n\n\tget size() {\n\t\treturn this.set.size;\n\t}\n\n\tadd( value ) {\n\t\tthis.set.add( value );\n\t\tthis.subscribers.forEach( ( subscriber ) => subscriber() );\n\t\treturn this;\n\t}\n\n\tdelete( value ) {\n\t\tconst isSuccess = this.set.delete( value );\n\t\tthis.subscribers.forEach( ( subscriber ) => subscriber() );\n\t\treturn isSuccess;\n\t}\n\n\tsubscribe( subscriber ) {\n\t\tthis.subscribers.add( subscriber );\n\t\treturn () => {\n\t\t\tthis.subscribers.delete( subscriber );\n\t\t};\n\t}\n}\n"],"mappings":";;;;;;;AAGA,IAAAA,iBAAA,GAAAC,sBAAA,CAAAC,OAAA;AAHA;AACA;AACA;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACe,SAASC,WAAWA,CAAEC,SAAS,GAAGC,yBAAgB,EAAG;EACnE,IAAIC,MAAM,GAAG,CAAC;EACd;EACA,IAAIC,KAAK,GAAG,EAAE;EACd,MAAMC,OAAO,GAAG,IAAIC,aAAa,CAAC,CAAC;EAEnC,OAAO;IACN;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;IACEC,GAAGA,CAAEC,Y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C,IAAI,CAACD,WAAW,CAACV,OAAO,CAAIY,UAAU,IAAMA,UAAU,CAAC,CAAE,CAAC;IAC1D,OAAOb,SAAS;EACjB;EAEAP,SAASA,CAAEoB,UAAU,EAAG;IACvB,IAAI,CAACF,WAAW,CAAC/B,GAAG,CAAEiC,UAAW,CAAC;IAClC,OAAO,MAAM;MACZ,IAAI,CAACF,WAAW,CAACvB,MAAM,CAAEyB,UAAW,CAAC;IACtC,CAAC;EACF;AACD","ignoreList":[]}
@@ -168,8 +168,16 @@ function sortResults(results, search) {
168
168
  for (const result of results) {
169
169
  if (result.title) {
170
170
  const titleTokens = tokenize(result.title);
171
- const matchingTokens = titleTokens.filter(titleToken => searchTokens.some(searchToken => titleToken.includes(searchToken)));
172
- scores[result.id] = matchingTokens.length / titleTokens.length;
171
+ const exactMatchingTokens = titleTokens.filter(titleToken => searchTokens.some(searchToken => titleToken === searchToken));
172
+ const subMatchingTokens = titleTokens.filter(titleToken => searchTokens.some(searchToken => titleToken !== searchToken && titleToken.includes(searchToken)));
173
+
174
+ // The score is a combination of exact matches and sub-matches.
175
+ // More weight is given to exact matches, as they are more relevant (e.g. "cat" vs "caterpillar").
176
+ // Diving by the total number of tokens in the title normalizes the score and skews
177
+ // the results towards shorter titles.
178
+ const exactMatchScore = exactMatchingTokens.length / titleTokens.length * 10;
179
+ const subMatchScore = subMatchingTokens.length / titleTokens.length;
180
+ scores[result.id] = exactMatchScore + subMatchScore;
173
181
  } else {
174
182
  scores[result.id] = 0;
175
183
  }
@@ -1 +1 @@
1
- {"version":3,"names":["_apiFetch","_interopRequireDefault","require","_url","_htmlEntities","_i18n","fetchLinkSuggestions","search","searchOptions","editorSettings","searchOptionsToUse","isInitialSuggestions","initialSuggestionsSearchOptions","type","subtype","page","perPage","disablePostFormats","queries","push","apiFetch","path","addQueryArgs","per_page","then","results","map","result","id","url","title","decodeEntities","__","kind","catch","source_url","rendered","responses","Promise","all","flat","filter","sortResults","slice","searchTokens","tokenize","scores","titleTokens","matchingTokens","titleToken","some","searchToken","includes","length","sort","a","b","text","toLowerCase","match"],"sources":["@wordpress/core-data/src/fetch/__experimental-fetch-link-suggestions.ts"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport apiFetch from '@wordpress/api-fetch';\nimport { addQueryArgs } from '@wordpress/url';\nimport { decodeEntities } from '@wordpress/html-entities';\nimport { __ } from '@wordpress/i18n';\n\nexport type SearchOptions = {\n\t/**\n\t * Displays initial search suggestions, when true.\n\t */\n\tisInitialSuggestions?: boolean;\n\t/**\n\t * Search options for initial suggestions.\n\t */\n\tinitialSuggestionsSearchOptions?: Omit<\n\t\tSearchOptions,\n\t\t'isInitialSuggestions' | 'initialSuggestionsSearchOptions'\n\t>;\n\t/**\n\t * Filters by search type.\n\t */\n\ttype?: 'attachment' | 'post' | 'term' | 'post-format';\n\t/**\n\t * Slug of the post-type or taxonomy.\n\t */\n\tsubtype?: string;\n\t/**\n\t * Which page of results to return.\n\t */\n\tpage?: number;\n\t/**\n\t * Search results per page.\n\t */\n\tperPage?: number;\n};\n\nexport type EditorSettings = {\n\t/**\n\t * Disables post formats, when true.\n\t */\n\tdisablePostFormats?: boolean;\n};\n\ntype SearchAPIResult = {\n\tid: number;\n\ttitle: string;\n\turl: string;\n\ttype: string;\n\tsubtype: string;\n};\n\ntype MediaAPIResult = {\n\tid: number;\n\ttitle: { rendered: string };\n\tsource_url: string;\n\ttype: string;\n};\n\nexport type SearchResult = {\n\t/**\n\t * Post or term id.\n\t */\n\tid: number;\n\t/**\n\t * Link url.\n\t */\n\turl: string;\n\t/**\n\t * Title of the link.\n\t */\n\ttitle: string;\n\t/**\n\t * The taxonomy or post type slug or type URL.\n\t */\n\ttype: string;\n\t/**\n\t * Link kind of post-type or taxonomy\n\t */\n\tkind?: string;\n};\n\n/**\n * Fetches link suggestions from the WordPress API.\n *\n * WordPress does not support searching multiple tables at once, e.g. posts and terms, so we\n * perform multiple queries at the same time and then merge the results together.\n *\n * @param search\n * @param searchOptions\n * @param editorSettings\n *\n * @example\n * ```js\n * import { __experimentalFetchLinkSuggestions as fetchLinkSuggestions } from '@wordpress/core-data';\n *\n * //...\n *\n * export function initialize( id, settings ) {\n *\n * settings.__experimentalFetchLinkSuggestions = (\n * search,\n * searchOptions\n * ) => fetchLinkSuggestions( search, searchOptions, settings );\n * ```\n */\nexport default async function fetchLinkSuggestions(\n\tsearch: string,\n\tsearchOptions: SearchOptions = {},\n\teditorSettings: EditorSettings = {}\n): Promise< SearchResult[] > {\n\tconst searchOptionsToUse =\n\t\tsearchOptions.isInitialSuggestions &&\n\t\tsearchOptions.initialSuggestionsSearchOptions\n\t\t\t? {\n\t\t\t\t\t...searchOptions,\n\t\t\t\t\t...searchOptions.initialSuggestionsSearchOptions,\n\t\t\t }\n\t\t\t: searchOptions;\n\n\tconst {\n\t\ttype,\n\t\tsubtype,\n\t\tpage,\n\t\tperPage = searchOptions.isInitialSuggestions ? 3 : 20,\n\t} = searchOptionsToUse;\n\n\tconst { disablePostFormats = false } = editorSettings;\n\n\tconst queries: Promise< SearchResult[] >[] = [];\n\n\tif ( ! type || type === 'post' ) {\n\t\tqueries.push(\n\t\t\tapiFetch< SearchAPIResult[] >( {\n\t\t\t\tpath: addQueryArgs( '/wp/v2/search', {\n\t\t\t\t\tsearch,\n\t\t\t\t\tpage,\n\t\t\t\t\tper_page: perPage,\n\t\t\t\t\ttype: 'post',\n\t\t\t\t\tsubtype,\n\t\t\t\t} ),\n\t\t\t} )\n\t\t\t\t.then( ( results ) => {\n\t\t\t\t\treturn results.map( ( result ) => {\n\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\tid: result.id,\n\t\t\t\t\t\t\turl: result.url,\n\t\t\t\t\t\t\ttitle:\n\t\t\t\t\t\t\t\tdecodeEntities( result.title || '' ) ||\n\t\t\t\t\t\t\t\t__( '(no title)' ),\n\t\t\t\t\t\t\ttype: result.subtype || result.type,\n\t\t\t\t\t\t\tkind: 'post-type',\n\t\t\t\t\t\t};\n\t\t\t\t\t} );\n\t\t\t\t} )\n\t\t\t\t.catch( () => [] ) // Fail by returning no results.\n\t\t);\n\t}\n\n\tif ( ! type || type === 'term' ) {\n\t\tqueries.push(\n\t\t\tapiFetch< SearchAPIResult[] >( {\n\t\t\t\tpath: addQueryArgs( '/wp/v2/search', {\n\t\t\t\t\tsearch,\n\t\t\t\t\tpage,\n\t\t\t\t\tper_page: perPage,\n\t\t\t\t\ttype: 'term',\n\t\t\t\t\tsubtype,\n\t\t\t\t} ),\n\t\t\t} )\n\t\t\t\t.then( ( results ) => {\n\t\t\t\t\treturn results.map( ( result ) => {\n\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\tid: result.id,\n\t\t\t\t\t\t\turl: result.url,\n\t\t\t\t\t\t\ttitle:\n\t\t\t\t\t\t\t\tdecodeEntities( result.title || '' ) ||\n\t\t\t\t\t\t\t\t__( '(no title)' ),\n\t\t\t\t\t\t\ttype: result.subtype || result.type,\n\t\t\t\t\t\t\tkind: 'taxonomy',\n\t\t\t\t\t\t};\n\t\t\t\t\t} );\n\t\t\t\t} )\n\t\t\t\t.catch( () => [] ) // Fail by returning no results.\n\t\t);\n\t}\n\n\tif ( ! disablePostFormats && ( ! type || type === 'post-format' ) ) {\n\t\tqueries.push(\n\t\t\tapiFetch< SearchAPIResult[] >( {\n\t\t\t\tpath: addQueryArgs( '/wp/v2/search', {\n\t\t\t\t\tsearch,\n\t\t\t\t\tpage,\n\t\t\t\t\tper_page: perPage,\n\t\t\t\t\ttype: 'post-format',\n\t\t\t\t\tsubtype,\n\t\t\t\t} ),\n\t\t\t} )\n\t\t\t\t.then( ( results ) => {\n\t\t\t\t\treturn results.map( ( result ) => {\n\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\tid: result.id,\n\t\t\t\t\t\t\turl: result.url,\n\t\t\t\t\t\t\ttitle:\n\t\t\t\t\t\t\t\tdecodeEntities( result.title || '' ) ||\n\t\t\t\t\t\t\t\t__( '(no title)' ),\n\t\t\t\t\t\t\ttype: result.subtype || result.type,\n\t\t\t\t\t\t\tkind: 'taxonomy',\n\t\t\t\t\t\t};\n\t\t\t\t\t} );\n\t\t\t\t} )\n\t\t\t\t.catch( () => [] ) // Fail by returning no results.\n\t\t);\n\t}\n\n\tif ( ! type || type === 'attachment' ) {\n\t\tqueries.push(\n\t\t\tapiFetch< MediaAPIResult[] >( {\n\t\t\t\tpath: addQueryArgs( '/wp/v2/media', {\n\t\t\t\t\tsearch,\n\t\t\t\t\tpage,\n\t\t\t\t\tper_page: perPage,\n\t\t\t\t} ),\n\t\t\t} )\n\t\t\t\t.then( ( results ) => {\n\t\t\t\t\treturn results.map( ( result ) => {\n\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\tid: result.id,\n\t\t\t\t\t\t\turl: result.source_url,\n\t\t\t\t\t\t\ttitle:\n\t\t\t\t\t\t\t\tdecodeEntities( result.title.rendered || '' ) ||\n\t\t\t\t\t\t\t\t__( '(no title)' ),\n\t\t\t\t\t\t\ttype: result.type,\n\t\t\t\t\t\t\tkind: 'media',\n\t\t\t\t\t\t};\n\t\t\t\t\t} );\n\t\t\t\t} )\n\t\t\t\t.catch( () => [] ) // Fail by returning no results.\n\t\t);\n\t}\n\n\tconst responses = await Promise.all( queries );\n\n\tlet results = responses.flat();\n\tresults = results.filter( ( result ) => !! result.id );\n\tresults = sortResults( results, search );\n\tresults = results.slice( 0, perPage );\n\treturn results;\n}\n\n/**\n * Sort search results by relevance to the given query.\n *\n * Sorting is necessary as we're querying multiple endpoints and merging the results. For example\n * a taxonomy title might be more relevant than a post title, but by default taxonomy results will\n * be ordered after all the (potentially irrelevant) post results.\n *\n * We sort by scoring each result, where the score is the number of tokens in the title that are\n * also in the search query, divided by the total number of tokens in the title. This gives us a\n * score between 0 and 1, where 1 is a perfect match.\n *\n * @param results\n * @param search\n */\nexport function sortResults( results: SearchResult[], search: string ) {\n\tconst searchTokens = tokenize( search );\n\n\tconst scores = {};\n\tfor ( const result of results ) {\n\t\tif ( result.title ) {\n\t\t\tconst titleTokens = tokenize( result.title );\n\t\t\tconst matchingTokens = titleTokens.filter( ( titleToken ) =>\n\t\t\t\tsearchTokens.some( ( searchToken ) =>\n\t\t\t\t\ttitleToken.includes( searchToken )\n\t\t\t\t)\n\t\t\t);\n\t\t\tscores[ result.id ] = matchingTokens.length / titleTokens.length;\n\t\t} else {\n\t\t\tscores[ result.id ] = 0;\n\t\t}\n\t}\n\n\treturn results.sort( ( a, b ) => scores[ b.id ] - scores[ a.id ] );\n}\n\n/**\n * Turns text into an array of tokens, with whitespace and punctuation removed.\n *\n * For example, `\"I'm having a ball.\"` becomes `[ \"im\", \"having\", \"a\", \"ball\" ]`.\n *\n * @param text\n */\nexport function tokenize( text: string ): string[] {\n\t// \\p{L} matches any kind of letter from any language.\n\t// \\p{N} matches any kind of numeric character.\n\treturn text.toLowerCase().match( /[\\p{L}\\p{N}]+/gu ) || [];\n}\n"],"mappings":";;;;;;;;;AAGA,IAAAA,SAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,IAAA,GAAAD,OAAA;AACA,IAAAE,aAAA,GAAAF,OAAA;AACA,IAAAG,KAAA,GAAAH,OAAA;AANA;AACA;AACA;;AAiFA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACe,eAAeI,oBAAoBA,CACjDC,MAAc,EACdC,aAA4B,GAAG,CAAC,CAAC,EACjCC,cAA8B,GAAG,CAAC,CAAC,EACP;EAC5B,MAAMC,kBAAkB,GACvBF,aAAa,CAACG,oBAAoB,IAClCH,aAAa,CAACI,+BAA+B,GAC1C;IACA,GAAGJ,aAAa;IAChB,GAAGA,aAAa,CAACI;EACjB,CAAC,GACDJ,aAAa;EAEjB,MAAM;IACLK,IAAI;IACJC,OAAO;IACPC,IAAI;IACJC,OAAO,GAAGR,aAAa,CAACG,oBAAoB,GAAG,CAAC,GAAG;EACpD,CAAC,GAAGD,kBAAkB;E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AAM,IAAIF,OAAO,EAAG;IAC/B,IAAKE,MAAM,CAACG,KAAK,EAAG;MACnB,MAAMiB,WAAW,GAAGF,QAAQ,CAAElB,MAAM,CAACG,KAAM,CAAC;MAC5C,MAAMkB,cAAc,GAAGD,WAAW,CAACN,MAAM,CAAIQ,UAAU,IACtDL,YAAY,CAACM,IAAI,CAAIC,WAAW,IAC/BF,UAAU,CAACG,QAAQ,CAAED,WAAY,CAClC,CACD,CAAC;MACDL,MAAM,CAAEnB,MAAM,CAACC,EAAE,CAAE,GAAGoB,cAAc,CAACK,MAAM,GAAGN,WAAW,CAACM,MAAM;IACjE,CAAC,MAAM;MACNP,MAAM,CAAEnB,MAAM,CAACC,EAAE,CAAE,GAAG,CAAC;IACxB;EACD;EAEA,OAAOH,OAAO,CAAC6B,IAAI,CAAE,CAAEC,CAAC,EAAEC,CAAC,KAAMV,MAAM,CAAEU,CAAC,CAAC5B,EAAE,CAAE,GAAGkB,MAAM,CAAES,CAAC,CAAC3B,EAAE,CAAG,CAAC;AACnE;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASiB,QAAQA,CAAEY,IAAY,EAAa;EAClD;EACA;EACA,OAAOA,IAAI,CAACC,WAAW,CAAC,CAAC,CAACC,KAAK,CAAE,iBAAkB,CAAC,IAAI,EAAE;AAC3D","ignoreList":[]}
1
+ {"version":3,"names":["_apiFetch","_interopRequireDefault","require","_url","_htmlEntities","_i18n","fetchLinkSuggestions","search","searchOptions","editorSettings","searchOptionsToUse","isInitialSuggestions","initialSuggestionsSearchOptions","type","subtype","page","perPage","disablePostFormats","queries","push","apiFetch","path","addQueryArgs","per_page","then","results","map","result","id","url","title","decodeEntities","__","kind","catch","source_url","rendered","responses","Promise","all","flat","filter","sortResults","slice","searchTokens","tokenize","scores","titleTokens","exactMatchingTokens","titleToken","some","searchToken","subMatchingTokens","includes","exactMatchScore","length","subMatchScore","sort","a","b","text","toLowerCase","match"],"sources":["@wordpress/core-data/src/fetch/__experimental-fetch-link-suggestions.ts"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport apiFetch from '@wordpress/api-fetch';\nimport { addQueryArgs } from '@wordpress/url';\nimport { decodeEntities } from '@wordpress/html-entities';\nimport { __ } from '@wordpress/i18n';\n\nexport type SearchOptions = {\n\t/**\n\t * Displays initial search suggestions, when true.\n\t */\n\tisInitialSuggestions?: boolean;\n\t/**\n\t * Search options for initial suggestions.\n\t */\n\tinitialSuggestionsSearchOptions?: Omit<\n\t\tSearchOptions,\n\t\t'isInitialSuggestions' | 'initialSuggestionsSearchOptions'\n\t>;\n\t/**\n\t * Filters by search type.\n\t */\n\ttype?: 'attachment' | 'post' | 'term' | 'post-format';\n\t/**\n\t * Slug of the post-type or taxonomy.\n\t */\n\tsubtype?: string;\n\t/**\n\t * Which page of results to return.\n\t */\n\tpage?: number;\n\t/**\n\t * Search results per page.\n\t */\n\tperPage?: number;\n};\n\nexport type EditorSettings = {\n\t/**\n\t * Disables post formats, when true.\n\t */\n\tdisablePostFormats?: boolean;\n};\n\ntype SearchAPIResult = {\n\tid: number;\n\ttitle: string;\n\turl: string;\n\ttype: string;\n\tsubtype: string;\n};\n\ntype MediaAPIResult = {\n\tid: number;\n\ttitle: { rendered: string };\n\tsource_url: string;\n\ttype: string;\n};\n\nexport type SearchResult = {\n\t/**\n\t * Post or term id.\n\t */\n\tid: number;\n\t/**\n\t * Link url.\n\t */\n\turl: string;\n\t/**\n\t * Title of the link.\n\t */\n\ttitle: string;\n\t/**\n\t * The taxonomy or post type slug or type URL.\n\t */\n\ttype: string;\n\t/**\n\t * Link kind of post-type or taxonomy\n\t */\n\tkind?: string;\n};\n\n/**\n * Fetches link suggestions from the WordPress API.\n *\n * WordPress does not support searching multiple tables at once, e.g. posts and terms, so we\n * perform multiple queries at the same time and then merge the results together.\n *\n * @param search\n * @param searchOptions\n * @param editorSettings\n *\n * @example\n * ```js\n * import { __experimentalFetchLinkSuggestions as fetchLinkSuggestions } from '@wordpress/core-data';\n *\n * //...\n *\n * export function initialize( id, settings ) {\n *\n * settings.__experimentalFetchLinkSuggestions = (\n * search,\n * searchOptions\n * ) => fetchLinkSuggestions( search, searchOptions, settings );\n * ```\n */\nexport default async function fetchLinkSuggestions(\n\tsearch: string,\n\tsearchOptions: SearchOptions = {},\n\teditorSettings: EditorSettings = {}\n): Promise< SearchResult[] > {\n\tconst searchOptionsToUse =\n\t\tsearchOptions.isInitialSuggestions &&\n\t\tsearchOptions.initialSuggestionsSearchOptions\n\t\t\t? {\n\t\t\t\t\t...searchOptions,\n\t\t\t\t\t...searchOptions.initialSuggestionsSearchOptions,\n\t\t\t }\n\t\t\t: searchOptions;\n\n\tconst {\n\t\ttype,\n\t\tsubtype,\n\t\tpage,\n\t\tperPage = searchOptions.isInitialSuggestions ? 3 : 20,\n\t} = searchOptionsToUse;\n\n\tconst { disablePostFormats = false } = editorSettings;\n\n\tconst queries: Promise< SearchResult[] >[] = [];\n\n\tif ( ! type || type === 'post' ) {\n\t\tqueries.push(\n\t\t\tapiFetch< SearchAPIResult[] >( {\n\t\t\t\tpath: addQueryArgs( '/wp/v2/search', {\n\t\t\t\t\tsearch,\n\t\t\t\t\tpage,\n\t\t\t\t\tper_page: perPage,\n\t\t\t\t\ttype: 'post',\n\t\t\t\t\tsubtype,\n\t\t\t\t} ),\n\t\t\t} )\n\t\t\t\t.then( ( results ) => {\n\t\t\t\t\treturn results.map( ( result ) => {\n\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\tid: result.id,\n\t\t\t\t\t\t\turl: result.url,\n\t\t\t\t\t\t\ttitle:\n\t\t\t\t\t\t\t\tdecodeEntities( result.title || '' ) ||\n\t\t\t\t\t\t\t\t__( '(no title)' ),\n\t\t\t\t\t\t\ttype: result.subtype || result.type,\n\t\t\t\t\t\t\tkind: 'post-type',\n\t\t\t\t\t\t};\n\t\t\t\t\t} );\n\t\t\t\t} )\n\t\t\t\t.catch( () => [] ) // Fail by returning no results.\n\t\t);\n\t}\n\n\tif ( ! type || type === 'term' ) {\n\t\tqueries.push(\n\t\t\tapiFetch< SearchAPIResult[] >( {\n\t\t\t\tpath: addQueryArgs( '/wp/v2/search', {\n\t\t\t\t\tsearch,\n\t\t\t\t\tpage,\n\t\t\t\t\tper_page: perPage,\n\t\t\t\t\ttype: 'term',\n\t\t\t\t\tsubtype,\n\t\t\t\t} ),\n\t\t\t} )\n\t\t\t\t.then( ( results ) => {\n\t\t\t\t\treturn results.map( ( result ) => {\n\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\tid: result.id,\n\t\t\t\t\t\t\turl: result.url,\n\t\t\t\t\t\t\ttitle:\n\t\t\t\t\t\t\t\tdecodeEntities( result.title || '' ) ||\n\t\t\t\t\t\t\t\t__( '(no title)' ),\n\t\t\t\t\t\t\ttype: result.subtype || result.type,\n\t\t\t\t\t\t\tkind: 'taxonomy',\n\t\t\t\t\t\t};\n\t\t\t\t\t} );\n\t\t\t\t} )\n\t\t\t\t.catch( () => [] ) // Fail by returning no results.\n\t\t);\n\t}\n\n\tif ( ! disablePostFormats && ( ! type || type === 'post-format' ) ) {\n\t\tqueries.push(\n\t\t\tapiFetch< SearchAPIResult[] >( {\n\t\t\t\tpath: addQueryArgs( '/wp/v2/search', {\n\t\t\t\t\tsearch,\n\t\t\t\t\tpage,\n\t\t\t\t\tper_page: perPage,\n\t\t\t\t\ttype: 'post-format',\n\t\t\t\t\tsubtype,\n\t\t\t\t} ),\n\t\t\t} )\n\t\t\t\t.then( ( results ) => {\n\t\t\t\t\treturn results.map( ( result ) => {\n\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\tid: result.id,\n\t\t\t\t\t\t\turl: result.url,\n\t\t\t\t\t\t\ttitle:\n\t\t\t\t\t\t\t\tdecodeEntities( result.title || '' ) ||\n\t\t\t\t\t\t\t\t__( '(no title)' ),\n\t\t\t\t\t\t\ttype: result.subtype || result.type,\n\t\t\t\t\t\t\tkind: 'taxonomy',\n\t\t\t\t\t\t};\n\t\t\t\t\t} );\n\t\t\t\t} )\n\t\t\t\t.catch( () => [] ) // Fail by returning no results.\n\t\t);\n\t}\n\n\tif ( ! type || type === 'attachment' ) {\n\t\tqueries.push(\n\t\t\tapiFetch< MediaAPIResult[] >( {\n\t\t\t\tpath: addQueryArgs( '/wp/v2/media', {\n\t\t\t\t\tsearch,\n\t\t\t\t\tpage,\n\t\t\t\t\tper_page: perPage,\n\t\t\t\t} ),\n\t\t\t} )\n\t\t\t\t.then( ( results ) => {\n\t\t\t\t\treturn results.map( ( result ) => {\n\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\tid: result.id,\n\t\t\t\t\t\t\turl: result.source_url,\n\t\t\t\t\t\t\ttitle:\n\t\t\t\t\t\t\t\tdecodeEntities( result.title.rendered || '' ) ||\n\t\t\t\t\t\t\t\t__( '(no title)' ),\n\t\t\t\t\t\t\ttype: result.type,\n\t\t\t\t\t\t\tkind: 'media',\n\t\t\t\t\t\t};\n\t\t\t\t\t} );\n\t\t\t\t} )\n\t\t\t\t.catch( () => [] ) // Fail by returning no results.\n\t\t);\n\t}\n\n\tconst responses = await Promise.all( queries );\n\n\tlet results = responses.flat();\n\tresults = results.filter( ( result ) => !! result.id );\n\tresults = sortResults( results, search );\n\tresults = results.slice( 0, perPage );\n\treturn results;\n}\n\n/**\n * Sort search results by relevance to the given query.\n *\n * Sorting is necessary as we're querying multiple endpoints and merging the results. For example\n * a taxonomy title might be more relevant than a post title, but by default taxonomy results will\n * be ordered after all the (potentially irrelevant) post results.\n *\n * We sort by scoring each result, where the score is the number of tokens in the title that are\n * also in the search query, divided by the total number of tokens in the title. This gives us a\n * score between 0 and 1, where 1 is a perfect match.\n *\n * @param results\n * @param search\n */\nexport function sortResults( results: SearchResult[], search: string ) {\n\tconst searchTokens = tokenize( search );\n\n\tconst scores = {};\n\tfor ( const result of results ) {\n\t\tif ( result.title ) {\n\t\t\tconst titleTokens = tokenize( result.title );\n\t\t\tconst exactMatchingTokens = titleTokens.filter( ( titleToken ) =>\n\t\t\t\tsearchTokens.some(\n\t\t\t\t\t( searchToken ) => titleToken === searchToken\n\t\t\t\t)\n\t\t\t);\n\t\t\tconst subMatchingTokens = titleTokens.filter( ( titleToken ) =>\n\t\t\t\tsearchTokens.some(\n\t\t\t\t\t( searchToken ) =>\n\t\t\t\t\t\ttitleToken !== searchToken &&\n\t\t\t\t\t\ttitleToken.includes( searchToken )\n\t\t\t\t)\n\t\t\t);\n\n\t\t\t// The score is a combination of exact matches and sub-matches.\n\t\t\t// More weight is given to exact matches, as they are more relevant (e.g. \"cat\" vs \"caterpillar\").\n\t\t\t// Diving by the total number of tokens in the title normalizes the score and skews\n\t\t\t// the results towards shorter titles.\n\t\t\tconst exactMatchScore =\n\t\t\t\t( exactMatchingTokens.length / titleTokens.length ) * 10;\n\n\t\t\tconst subMatchScore = subMatchingTokens.length / titleTokens.length;\n\n\t\t\tscores[ result.id ] = exactMatchScore + subMatchScore;\n\t\t} else {\n\t\t\tscores[ result.id ] = 0;\n\t\t}\n\t}\n\n\treturn results.sort( ( a, b ) => scores[ b.id ] - scores[ a.id ] );\n}\n\n/**\n * Turns text into an array of tokens, with whitespace and punctuation removed.\n *\n * For example, `\"I'm having a ball.\"` becomes `[ \"im\", \"having\", \"a\", \"ball\" ]`.\n *\n * @param text\n */\nexport function tokenize( text: string ): string[] {\n\t// \\p{L} matches any kind of letter from any language.\n\t// \\p{N} matches any kind of numeric character.\n\treturn text.toLowerCase().match( /[\\p{L}\\p{N}]+/gu ) || [];\n}\n"],"mappings":";;;;;;;;;AAGA,IAAAA,SAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,IAAA,GAAAD,OAAA;AACA,IAAAE,aAAA,GAAAF,OAAA;AACA,IAAAG,KAAA,GAAAH,OAAA;AANA;AACA;AACA;;AAiFA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACe,eAAeI,oBAAoBA,CACjDC,MAAc,E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CAAC,CAAC/B,EAAE,CAAE,GAAGkB,MAAM,CAAEY,CAAC,CAAC9B,EAAE,CAAG,CAAC;AACnE;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASiB,QAAQA,CAAEe,IAAY,EAAa;EAClD;EACA;EACA,OAAOA,IAAI,CAACC,WAAW,CAAC,CAAC,CAACC,KAAK,CAAE,iBAAkB,CAAC,IAAI,EAAE;AAC3D","ignoreList":[]}
@@ -123,9 +123,7 @@ const getHomePage = exports.getHomePage = (0, _data.createRegistrySelector)(sele
123
123
  postType: 'wp_template',
124
124
  postId: frontPageTemplateId
125
125
  };
126
- }, state => [
127
- // @ts-expect-error
128
- (0, _selectors.getEntityRecord)(state, 'root', 'site'), (0, _selectors.getDefaultTemplateId)(state, {
126
+ }, state => [(0, _selectors.getEntityRecord)(state, 'root', 'site'), (0, _selectors.getDefaultTemplateId)(state, {
129
127
  slug: 'front-page'
130
128
  })]));
131
129
  const getPostsPageId = exports.getPostsPageId = (0, _data.createRegistrySelector)(select => () => {
@@ -1 +1 @@
1
- {"version":3,"names":["_data","require","_selectors","_name","_lockUnlock","getUndoManager","state","undoManager","getNavigationFallbackId","navigationFallbackId","getBlockPatternsForPostType","exports","createRegistrySelector","select","createSelector","postType","STORE_NAME","getBlockPatterns","filter","postTypes","Array","isArray","includes","getEntityRecordsPermissions","kind","name","ids","normalizedIds","map","id","delete","canUser","update","userPermissions","getEntityRecordPermissions","getRegisteredPostMeta","_state$registeredPost","registeredPostMeta","normalizePageId","value","Number","toString","getHomePage","siteData","getEntityRecord","homepageId","show_on_front","page_on_front","postId","frontPageTemplateId","getDefaultTemplateId","slug","getPostsPageId","page_for_posts","getTemplateId","homepage","unlock","templates","getEntityRecords","per_page","find","editedEntity","getEditedEntityRecord","postsPageId","currentTemplateSlug","template","currentTemplate","slugToCheck"],"sources":["@wordpress/core-data/src/private-selectors.ts"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { createSelector, createRegistrySelector } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport { getDefaultTemplateId, getEntityRecord, type State } from './selectors';\nimport { STORE_NAME } from './name';\nimport { unlock } from './lock-unlock';\n\ntype EntityRecordKey = string | number;\n\n/**\n * Returns the previous edit from the current undo offset\n * for the entity records edits history, if any.\n *\n * @param state State tree.\n *\n * @return The undo manager.\n */\nexport function getUndoManager( state: State ) {\n\treturn state.undoManager;\n}\n\n/**\n * Retrieve the fallback Navigation.\n *\n * @param state Data state.\n * @return The ID for the fallback Navigation post.\n */\nexport function getNavigationFallbackId(\n\tstate: State\n): EntityRecordKey | undefined {\n\treturn state.navigationFallbackId;\n}\n\nexport const getBlockPatternsForPostType = createRegistrySelector(\n\t( select: any ) =>\n\t\tcreateSelector(\n\t\t\t( state, postType ) =>\n\t\t\t\tselect( STORE_NAME )\n\t\t\t\t\t.getBlockPatterns()\n\t\t\t\t\t.filter(\n\t\t\t\t\t\t( { postTypes } ) =>\n\t\t\t\t\t\t\t! postTypes ||\n\t\t\t\t\t\t\t( Array.isArray( postTypes ) &&\n\t\t\t\t\t\t\t\tpostTypes.includes( postType ) )\n\t\t\t\t\t),\n\t\t\t() => [ select( STORE_NAME ).getBlockPatterns() ]\n\t\t)\n);\n\n/**\n * Returns the entity records permissions for the given entity record ids.\n */\nexport const getEntityRecordsPermissions = createRegistrySelector( ( select ) =>\n\tcreateSelector(\n\t\t( state: State, kind: string, name: string, ids: string[] ) => {\n\t\t\tconst normalizedIds = Array.isArray( ids ) ? ids : [ ids ];\n\t\t\treturn normalizedIds.map( ( id ) => ( {\n\t\t\t\tdelete: select( STORE_NAME ).canUser( 'delete', {\n\t\t\t\t\tkind,\n\t\t\t\t\tname,\n\t\t\t\t\tid,\n\t\t\t\t} ),\n\t\t\t\tupdate: select( STORE_NAME ).canUser( 'update', {\n\t\t\t\t\tkind,\n\t\t\t\t\tname,\n\t\t\t\t\tid,\n\t\t\t\t} ),\n\t\t\t} ) );\n\t\t},\n\t\t( state ) => [ state.userPermissions ]\n\t)\n);\n\n/**\n * Returns the entity record permissions for the given entity record id.\n *\n * @param state Data state.\n * @param kind Entity kind.\n * @param name Entity name.\n * @param id Entity record id.\n *\n * @return The entity record permissions.\n */\nexport function getEntityRecordPermissions(\n\tstate: State,\n\tkind: string,\n\tname: string,\n\tid: string\n) {\n\treturn getEntityRecordsPermissions( state, kind, name, id )[ 0 ];\n}\n\n/**\n * Returns the registered post meta fields for a given post type.\n *\n * @param state Data state.\n * @param postType Post type.\n *\n * @return Registered post meta fields.\n */\nexport function getRegisteredPostMeta( state: State, postType: string ) {\n\treturn state.registeredPostMeta?.[ postType ] ?? {};\n}\n\nfunction normalizePageId( value: number | string | undefined ): string | null {\n\tif ( ! value || ! [ 'number', 'string' ].includes( typeof value ) ) {\n\t\treturn null;\n\t}\n\n\t// We also need to check if it's not zero (`'0'`).\n\tif ( Number( value ) === 0 ) {\n\t\treturn null;\n\t}\n\n\treturn value.toString();\n}\n\ninterface SiteData {\n\tshow_on_front?: string;\n\tpage_on_front?: string | number;\n\tpage_for_posts?: string | number;\n}\n\nexport const getHomePage = createRegistrySelector( ( select ) =>\n\tcreateSelector(\n\t\t() => {\n\t\t\tconst siteData = select( STORE_NAME ).getEntityRecord(\n\t\t\t\t'root',\n\t\t\t\t'site'\n\t\t\t) as SiteData | undefined;\n\t\t\tif ( ! siteData ) {\n\t\t\t\treturn null;\n\t\t\t}\n\t\t\tconst homepageId =\n\t\t\t\tsiteData?.show_on_front === 'page'\n\t\t\t\t\t? normalizePageId( siteData.page_on_front )\n\t\t\t\t\t: null;\n\t\t\tif ( homepageId ) {\n\t\t\t\treturn { postType: 'page', postId: homepageId };\n\t\t\t}\n\t\t\tconst frontPageTemplateId = select(\n\t\t\t\tSTORE_NAME\n\t\t\t).getDefaultTemplateId( {\n\t\t\t\tslug: 'front-page',\n\t\t\t} );\n\t\t\treturn { postType: 'wp_template', postId: frontPageTemplateId };\n\t\t},\n\t\t( state ) => [\n\t\t\t// @ts-expect-error\n\t\t\tgetEntityRecord( state, 'root', 'site' ),\n\t\t\tgetDefaultTemplateId( state, {\n\t\t\t\tslug: 'front-page',\n\t\t\t} ),\n\t\t]\n\t)\n);\n\nexport const getPostsPageId = createRegistrySelector( ( select ) => () => {\n\tconst siteData = select( STORE_NAME ).getEntityRecord( 'root', 'site' ) as\n\t\t| SiteData\n\t\t| undefined;\n\treturn siteData?.show_on_front === 'page'\n\t\t? normalizePageId( siteData.page_for_posts )\n\t\t: null;\n} );\n\nexport const getTemplateId = createRegistrySelector(\n\t( select ) => ( state, postType, postId ) => {\n\t\tconst homepage = unlock( select( STORE_NAME ) ).getHomePage();\n\n\t\tif ( ! homepage ) {\n\t\t\treturn;\n\t\t}\n\n\t\t// For the front page, we always use the front page template if existing.\n\t\tif (\n\t\t\tpostType === 'page' &&\n\t\t\tpostType === homepage?.postType &&\n\t\t\tpostId.toString() === homepage?.postId\n\t\t) {\n\t\t\t// The /lookup endpoint cannot currently handle a lookup\n\t\t\t// when a page is set as the front page, so specifically in\n\t\t\t// that case, we want to check if there is a front page\n\t\t\t// template, and instead of falling back to the home\n\t\t\t// template, we want to fall back to the page template.\n\t\t\tconst templates = select( STORE_NAME ).getEntityRecords(\n\t\t\t\t'postType',\n\t\t\t\t'wp_template',\n\t\t\t\t{\n\t\t\t\t\tper_page: -1,\n\t\t\t\t}\n\t\t\t);\n\t\t\tif ( ! templates ) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tconst id = templates.find( ( { slug } ) => slug === 'front-page' )\n\t\t\t\t?.id;\n\t\t\tif ( id ) {\n\t\t\t\treturn id;\n\t\t\t}\n\t\t\t// If no front page template is found, continue with the\n\t\t\t// logic below (fetching the page template).\n\t\t}\n\n\t\tconst editedEntity = select( STORE_NAME ).getEditedEntityRecord(\n\t\t\t'postType',\n\t\t\tpostType,\n\t\t\tpostId\n\t\t);\n\t\tif ( ! editedEntity ) {\n\t\t\treturn;\n\t\t}\n\t\tconst postsPageId = unlock( select( STORE_NAME ) ).getPostsPageId();\n\t\t// Check if the current page is the posts page.\n\t\tif ( postType === 'page' && postsPageId === postId.toString() ) {\n\t\t\treturn select( STORE_NAME ).getDefaultTemplateId( {\n\t\t\t\tslug: 'home',\n\t\t\t} );\n\t\t}\n\t\t// First see if the post/page has an assigned template and fetch it.\n\t\tconst currentTemplateSlug = editedEntity.template;\n\t\tif ( currentTemplateSlug ) {\n\t\t\tconst currentTemplate = select( STORE_NAME )\n\t\t\t\t.getEntityRecords( 'postType', 'wp_template', {\n\t\t\t\t\tper_page: -1,\n\t\t\t\t} )\n\t\t\t\t?.find( ( { slug } ) => slug === currentTemplateSlug );\n\t\t\tif ( currentTemplate ) {\n\t\t\t\treturn currentTemplate.id;\n\t\t\t}\n\t\t}\n\t\t// If no template is assigned, use the default template.\n\t\tlet slugToCheck;\n\t\t// In `draft` status we might not have a slug available, so we use the `single`\n\t\t// post type templates slug(ex page, single-post, single-product etc..).\n\t\t// Pages do not need the `single` prefix in the slug to be prioritized\n\t\t// through template hierarchy.\n\t\tif ( editedEntity.slug ) {\n\t\t\tslugToCheck =\n\t\t\t\tpostType === 'page'\n\t\t\t\t\t? `${ postType }-${ editedEntity.slug }`\n\t\t\t\t\t: `single-${ postType }-${ editedEntity.slug }`;\n\t\t} else {\n\t\t\tslugToCheck = postType === 'page' ? 'page' : `single-${ postType }`;\n\t\t}\n\t\treturn select( STORE_NAME ).getDefaultTemplateId( {\n\t\t\tslug: slugToCheck,\n\t\t} );\n\t}\n);\n"],"mappings":";;;;;;;;;;;;;AAGA,IAAAA,KAAA,GAAAC,OAAA;AAKA,IAAAC,UAAA,GAAAD,OAAA;AACA,IAAAE,KAAA,GAAAF,OAAA;AACA,IAAAG,WAAA,GAAAH,OAAA;AAVA;AACA;AACA;;AAGA;AACA;AACA;;AAOA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASI,cAAcA,CAAEC,KAAY,EAAG;EAC9C,OAAOA,KAAK,CAACC,WAAW;AACzB;;AAEA;AACA;AACA;AACA;AACA;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ACA,IAAKN,YAAY,CAACV,IAAI,EAAG;IACxBgB,WAAW,GACVpD,QAAQ,KAAK,MAAM,GAChB,GAAIA,QAAQ,IAAM8C,YAAY,CAACV,IAAI,EAAG,GACtC,UAAWpC,QAAQ,IAAM8C,YAAY,CAACV,IAAI,EAAG;EAClD,CAAC,MAAM;IACNgB,WAAW,GAAGpD,QAAQ,KAAK,MAAM,GAAG,MAAM,GAAG,UAAWA,QAAQ,EAAG;EACpE;EACA,OAAOF,MAAM,CAAEG,gBAAW,CAAC,CAACkC,oBAAoB,CAAE;IACjDC,IAAI,EAAEgB;EACP,CAAE,CAAC;AACJ,CACD,CAAC","ignoreList":[]}
1
+ {"version":3,"names":["_data","require","_selectors","_name","_lockUnlock","getUndoManager","state","undoManager","getNavigationFallbackId","navigationFallbackId","getBlockPatternsForPostType","exports","createRegistrySelector","select","createSelector","postType","STORE_NAME","getBlockPatterns","filter","postTypes","Array","isArray","includes","getEntityRecordsPermissions","kind","name","ids","normalizedIds","map","id","delete","canUser","update","userPermissions","getEntityRecordPermissions","getRegisteredPostMeta","_state$registeredPost","registeredPostMeta","normalizePageId","value","Number","toString","getHomePage","siteData","getEntityRecord","homepageId","show_on_front","page_on_front","postId","frontPageTemplateId","getDefaultTemplateId","slug","getPostsPageId","page_for_posts","getTemplateId","homepage","unlock","templates","getEntityRecords","per_page","find","editedEntity","getEditedEntityRecord","postsPageId","currentTemplateSlug","template","currentTemplate","slugToCheck"],"sources":["@wordpress/core-data/src/private-selectors.ts"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { createSelector, createRegistrySelector } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport { getDefaultTemplateId, getEntityRecord, type State } from './selectors';\nimport { STORE_NAME } from './name';\nimport { unlock } from './lock-unlock';\n\ntype EntityRecordKey = string | number;\n\n/**\n * Returns the previous edit from the current undo offset\n * for the entity records edits history, if any.\n *\n * @param state State tree.\n *\n * @return The undo manager.\n */\nexport function getUndoManager( state: State ) {\n\treturn state.undoManager;\n}\n\n/**\n * Retrieve the fallback Navigation.\n *\n * @param state Data state.\n * @return The ID for the fallback Navigation post.\n */\nexport function getNavigationFallbackId(\n\tstate: State\n): EntityRecordKey | undefined {\n\treturn state.navigationFallbackId;\n}\n\nexport const getBlockPatternsForPostType = createRegistrySelector(\n\t( select: any ) =>\n\t\tcreateSelector(\n\t\t\t( state, postType ) =>\n\t\t\t\tselect( STORE_NAME )\n\t\t\t\t\t.getBlockPatterns()\n\t\t\t\t\t.filter(\n\t\t\t\t\t\t( { postTypes } ) =>\n\t\t\t\t\t\t\t! postTypes ||\n\t\t\t\t\t\t\t( Array.isArray( postTypes ) &&\n\t\t\t\t\t\t\t\tpostTypes.includes( postType ) )\n\t\t\t\t\t),\n\t\t\t() => [ select( STORE_NAME ).getBlockPatterns() ]\n\t\t)\n);\n\n/**\n * Returns the entity records permissions for the given entity record ids.\n */\nexport const getEntityRecordsPermissions = createRegistrySelector( ( select ) =>\n\tcreateSelector(\n\t\t( state: State, kind: string, name: string, ids: string[] ) => {\n\t\t\tconst normalizedIds = Array.isArray( ids ) ? ids : [ ids ];\n\t\t\treturn normalizedIds.map( ( id ) => ( {\n\t\t\t\tdelete: select( STORE_NAME ).canUser( 'delete', {\n\t\t\t\t\tkind,\n\t\t\t\t\tname,\n\t\t\t\t\tid,\n\t\t\t\t} ),\n\t\t\t\tupdate: select( STORE_NAME ).canUser( 'update', {\n\t\t\t\t\tkind,\n\t\t\t\t\tname,\n\t\t\t\t\tid,\n\t\t\t\t} ),\n\t\t\t} ) );\n\t\t},\n\t\t( state ) => [ state.userPermissions ]\n\t)\n);\n\n/**\n * Returns the entity record permissions for the given entity record id.\n *\n * @param state Data state.\n * @param kind Entity kind.\n * @param name Entity name.\n * @param id Entity record id.\n *\n * @return The entity record permissions.\n */\nexport function getEntityRecordPermissions(\n\tstate: State,\n\tkind: string,\n\tname: string,\n\tid: string\n) {\n\treturn getEntityRecordsPermissions( state, kind, name, id )[ 0 ];\n}\n\n/**\n * Returns the registered post meta fields for a given post type.\n *\n * @param state Data state.\n * @param postType Post type.\n *\n * @return Registered post meta fields.\n */\nexport function getRegisteredPostMeta( state: State, postType: string ) {\n\treturn state.registeredPostMeta?.[ postType ] ?? {};\n}\n\nfunction normalizePageId( value: number | string | undefined ): string | null {\n\tif ( ! value || ! [ 'number', 'string' ].includes( typeof value ) ) {\n\t\treturn null;\n\t}\n\n\t// We also need to check if it's not zero (`'0'`).\n\tif ( Number( value ) === 0 ) {\n\t\treturn null;\n\t}\n\n\treturn value.toString();\n}\n\ninterface SiteData {\n\tshow_on_front?: string;\n\tpage_on_front?: string | number;\n\tpage_for_posts?: string | number;\n}\n\nexport const getHomePage = createRegistrySelector( ( select ) =>\n\tcreateSelector(\n\t\t() => {\n\t\t\tconst siteData = select( STORE_NAME ).getEntityRecord(\n\t\t\t\t'root',\n\t\t\t\t'site'\n\t\t\t) as SiteData | undefined;\n\t\t\tif ( ! siteData ) {\n\t\t\t\treturn null;\n\t\t\t}\n\t\t\tconst homepageId =\n\t\t\t\tsiteData?.show_on_front === 'page'\n\t\t\t\t\t? normalizePageId( siteData.page_on_front )\n\t\t\t\t\t: null;\n\t\t\tif ( homepageId ) {\n\t\t\t\treturn { postType: 'page', postId: homepageId };\n\t\t\t}\n\t\t\tconst frontPageTemplateId = select(\n\t\t\t\tSTORE_NAME\n\t\t\t).getDefaultTemplateId( {\n\t\t\t\tslug: 'front-page',\n\t\t\t} );\n\t\t\treturn { postType: 'wp_template', postId: frontPageTemplateId };\n\t\t},\n\t\t( state ) => [\n\t\t\tgetEntityRecord( state, 'root', 'site' ),\n\t\t\tgetDefaultTemplateId( state, {\n\t\t\t\tslug: 'front-page',\n\t\t\t} ),\n\t\t]\n\t)\n);\n\nexport const getPostsPageId = createRegistrySelector( ( select ) => () => {\n\tconst siteData = select( STORE_NAME ).getEntityRecord( 'root', 'site' ) as\n\t\t| SiteData\n\t\t| undefined;\n\treturn siteData?.show_on_front === 'page'\n\t\t? normalizePageId( siteData.page_for_posts )\n\t\t: null;\n} );\n\nexport const getTemplateId = createRegistrySelector(\n\t( select ) => ( state, postType, postId ) => {\n\t\tconst homepage = unlock( select( STORE_NAME ) ).getHomePage();\n\n\t\tif ( ! homepage ) {\n\t\t\treturn;\n\t\t}\n\n\t\t// For the front page, we always use the front page template if existing.\n\t\tif (\n\t\t\tpostType === 'page' &&\n\t\t\tpostType === homepage?.postType &&\n\t\t\tpostId.toString() === homepage?.postId\n\t\t) {\n\t\t\t// The /lookup endpoint cannot currently handle a lookup\n\t\t\t// when a page is set as the front page, so specifically in\n\t\t\t// that case, we want to check if there is a front page\n\t\t\t// template, and instead of falling back to the home\n\t\t\t// template, we want to fall back to the page template.\n\t\t\tconst templates = select( STORE_NAME ).getEntityRecords(\n\t\t\t\t'postType',\n\t\t\t\t'wp_template',\n\t\t\t\t{\n\t\t\t\t\tper_page: -1,\n\t\t\t\t}\n\t\t\t);\n\t\t\tif ( ! templates ) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tconst id = templates.find( ( { slug } ) => slug === 'front-page' )\n\t\t\t\t?.id;\n\t\t\tif ( id ) {\n\t\t\t\treturn id;\n\t\t\t}\n\t\t\t// If no front page template is found, continue with the\n\t\t\t// logic below (fetching the page template).\n\t\t}\n\n\t\tconst editedEntity = select( STORE_NAME ).getEditedEntityRecord(\n\t\t\t'postType',\n\t\t\tpostType,\n\t\t\tpostId\n\t\t);\n\t\tif ( ! editedEntity ) {\n\t\t\treturn;\n\t\t}\n\t\tconst postsPageId = unlock( select( STORE_NAME ) ).getPostsPageId();\n\t\t// Check if the current page is the posts page.\n\t\tif ( postType === 'page' && postsPageId === postId.toString() ) {\n\t\t\treturn select( STORE_NAME ).getDefaultTemplateId( {\n\t\t\t\tslug: 'home',\n\t\t\t} );\n\t\t}\n\t\t// First see if the post/page has an assigned template and fetch it.\n\t\tconst currentTemplateSlug = editedEntity.template;\n\t\tif ( currentTemplateSlug ) {\n\t\t\tconst currentTemplate = select( STORE_NAME )\n\t\t\t\t.getEntityRecords( 'postType', 'wp_template', {\n\t\t\t\t\tper_page: -1,\n\t\t\t\t} )\n\t\t\t\t?.find( ( { slug } ) => slug === currentTemplateSlug );\n\t\t\tif ( currentTemplate ) {\n\t\t\t\treturn currentTemplate.id;\n\t\t\t}\n\t\t}\n\t\t// If no template is assigned, use the default template.\n\t\tlet slugToCheck;\n\t\t// In `draft` status we might not have a slug available, so we use the `single`\n\t\t// post type templates slug(ex page, single-post, single-product etc..).\n\t\t// Pages do not need the `single` prefix in the slug to be prioritized\n\t\t// through template hierarchy.\n\t\tif ( editedEntity.slug ) {\n\t\t\tslugToCheck =\n\t\t\t\tpostType === 'page'\n\t\t\t\t\t? `${ postType }-${ editedEntity.slug }`\n\t\t\t\t\t: `single-${ postType }-${ editedEntity.slug }`;\n\t\t} else {\n\t\t\tslugToCheck = postType === 'page' ? 'page' : `single-${ postType }`;\n\t\t}\n\t\treturn select( STORE_NAME ).getDefaultTemplateId( {\n\t\t\tslug: slugToCheck,\n\t\t} );\n\t}\n);\n"],"mappings":";;;;;;;;;;;;;AAGA,IAAAA,KAAA,GAAAC,OAAA;AAKA,IAAAC,UAAA,GAAAD,OAAA;AACA,IAAAE,KAAA,GAAAF,OAAA;AACA,IAAAG,WAAA,GAAAH,OAAA;AAVA;AACA;AACA;;AAGA;AACA;AACA;;AAOA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASI,cAAcA,CAAEC,KAAY,EAAG;EAC9C,OAAOA,KAAK,CAACC,WAAW;AACzB;;AAEA;AACA;AACA;AACA;AACA;AACA;AACO,SAASC,uBAAuBA,CACtCF,KAAY,EACkB;EAC9B,OAAOA,KAAK,CAACG,oBAAoB;AAClC;AAEO,MAAMC,2BAA2B,GAAAC,OAAA,CAAAD,2BAAA,GAAG,IAAAE,4BAAsB,EAC9DC,MAAW,IACZ,IAAAC,oBAAc,EACb,CAAER,KAAK,EAAES,QAAQ,KAChBF,MAAM,CAAEG,gBAAW,CAAC,CAClB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A,QAAQ,EAAG;EACpE;EACA,OAAOF,MAAM,CAAEG,gBAAW,CAAC,CAACkC,oBAAoB,CAAE;IACjDC,IAAI,EAAEgB;EACP,CAAE,CAAC;AACJ,CACD,CAAC","ignoreList":[]}
@@ -1,4 +1,3 @@
1
- /* wp:polyfill */
2
1
  "use strict";
3
2
 
4
3
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
@@ -1 +1 @@
1
- {"version":3,"names":["_changeCase","require","_url","_htmlEntities","_apiFetch","_interopRequireDefault","_name","_entities","_utils","_sync","_fetch","getAuthors","query","dispatch","path","addQueryArgs","users","apiFetch","receiveUserQuery","exports","getCurrentUser","currentUser","receiveCurrentUser","getEntityRecord","kind","name","key","select","registry","resolveSelect","configs","getEntitiesConfig","entityConfig","find","config","lock","__unstableAcquireStoreLock","STORE_NAME","exclusive","window","__experimentalEnableSync","syncConfig","globalThis","IS_GUTENBERG_PLUGIN","objectId","getSyncObjectId","getSyncProvider","bootstrap","syncObjectType","record","receiveEntityRecords","type","recordId","edits","meta","undo","undefined","_fields","Set","getNormalizedCommaSeparable","DEFAULT_ENTITY_KEY","join","baseURL","baseURLParams","include","hasRecords","hasEntityRecords","response","parse","json","permissions","getUserPermissionsFromAllowHeader","headers","get","canUserResolutionsArgs","receiveUserPermissionArgs","action","ALLOWED_RESOURCE_ACTIONS","getUserPermissionCacheKey","id","push","batch","receiveUserPermissions","finishResolutions","__unstableReleaseStoreLock","getRawEntityRecord","forwardResolver","getEditedEntityRecord","getEntityRecords","getResolutionsArgs","records","filter","map","supportsPagination","per_page","Object","values","totalItems","parseInt","totalPages","RECEIVE_INTERMEDIATE_RESULTS","page","pageRecords","length","split","forEach","field","hasOwnProperty","context","targetHints","_links","self","allow","targetHint","e","shouldInvalidate","invalidateCache","getCurrentTheme","activeThemes","status","receiveCurrentTheme","getThemeSupports","getEmbedPreview","url","embedProxyResponse","receiveEmbedPreview","error","canUser","requestedAction","resource","includes","Error","hasStartedResolution","relatedAction","isAlreadyResolving","resourcePath","method","receiveUserPermission","finishResolution","canUserEditEntityRecord","getAutosaves","postType","postId","rest_base","restBase","rest_namespace","restNamespace","getPostType","autosaves","receiveAutosaves","getAutosave","__experimentalGetCurrentGlobalStylesId","globalStylesURL","href","matches","match","Number","__experimentalReceiveCurrentGlobalStylesId","__experimentalGetCurrentThemeBaseGlobalStyles","currentTheme","themeGlobalStyles","stylesheet","__experimentalReceiveThemeBaseGlobalStyles","__experimentalGetCurrentThemeGlobalStylesVariations","variations","__experimentalReceiveThemeGlobalStyleVariations","getCurrentThemeGlobalStylesRevisions","globalStylesId","revisionsURL","resetRevisions","revisions","revision","fromEntries","entries","value","camelCase","receiveThemeGlobalStyleRevisions","getBlockPatterns","patterns","fetchBlockPatterns","getBlockPatternCategories","categories","getUserPatternCategories","patternCategories","mappedPatternCategories","userCategory","label","decodeEntities","slug","getNavigationFallbackId","fallback","_embed","_embedded","receiveNavigationFallbackId","existingFallbackEntityRecord","invalidateNavigationQueries","getDefaultTemplateId","template","receiveDefaultTemplateId","getRevisions","recordKey","revisionKey","getRevisionsUrl","isPaginated","receiveRevisions","resolutionsArgs","getRevision","getRegisteredPostMeta","options","receiveRegisteredPostMeta","schema","properties","loader","additionalEntityConfigLoaders","l","loadEntities","addEntities"],"sources":["@wordpress/core-data/src/resolvers.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport { camelCase } from 'change-case';\n\n/**\n * WordPress dependencies\n */\nimport { addQueryArgs } from '@wordpress/url';\nimport { decodeEntities } from '@wordpress/html-entities';\nimport apiFetch from '@wordpress/api-fetch';\n\n/**\n * Internal dependencies\n */\nimport { STORE_NAME } from './name';\nimport { additionalEntityConfigLoaders, DEFAULT_ENTITY_KEY } from './entities';\nimport {\n\tforwardResolver,\n\tgetNormalizedCommaSeparable,\n\tgetUserPermissionCacheKey,\n\tgetUserPermissionsFromAllowHeader,\n\tALLOWED_RESOURCE_ACTIONS,\n\tRECEIVE_INTERMEDIATE_RESULTS,\n} from './utils';\nimport { getSyncProvider } from './sync';\nimport { fetchBlockPatterns } from './fetch';\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, registry, resolveSelect } ) => {\n\t\tconst configs = await resolveSelect.getEntitiesConfig( 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 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\t// Entity supports configs,\n\t\t\t// use the sync algorithm instead of the old fetch behavior.\n\t\t\tif (\n\t\t\t\twindow.__experimentalEnableSync &&\n\t\t\t\tentityConfig.syncConfig &&\n\t\t\t\t! query\n\t\t\t) {\n\t\t\t\tif ( globalThis.IS_GUTENBERG_PLUGIN ) {\n\t\t\t\t\tconst objectId = entityConfig.getSyncObjectId( key );\n\n\t\t\t\t\t// Loads the persisted document.\n\t\t\t\t\tawait getSyncProvider().bootstrap(\n\t\t\t\t\t\tentityConfig.syncObjectType,\n\t\t\t\t\t\tobjectId,\n\t\t\t\t\t\t( record ) => {\n\t\t\t\t\t\t\tdispatch.receiveEntityRecords(\n\t\t\t\t\t\t\t\tkind,\n\t\t\t\t\t\t\t\tname,\n\t\t\t\t\t\t\t\trecord,\n\t\t\t\t\t\t\t\tquery\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}\n\t\t\t\t\t);\n\n\t\t\t\t\t// Boostraps the edited document as well (and load from peers).\n\t\t\t\t\tawait getSyncProvider().bootstrap(\n\t\t\t\t\t\tentityConfig.syncObjectType + '--edit',\n\t\t\t\t\t\tobjectId,\n\t\t\t\t\t\t( record ) => {\n\t\t\t\t\t\t\tdispatch( {\n\t\t\t\t\t\t\t\ttype: 'EDIT_ENTITY_RECORD',\n\t\t\t\t\t\t\t\tkind,\n\t\t\t\t\t\t\t\tname,\n\t\t\t\t\t\t\t\trecordId: key,\n\t\t\t\t\t\t\t\tedits: record,\n\t\t\t\t\t\t\t\tmeta: {\n\t\t\t\t\t\t\t\t\tundo: undefined,\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t} );\n\t\t\t\t\t\t}\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tif ( query !== undefined && query._fields ) {\n\t\t\t\t\t// If requesting specific fields, items and query association to said\n\t\t\t\t\t// records are stored by ID reference. Thus, fields must always include\n\t\t\t\t\t// the ID.\n\t\t\t\t\tquery = {\n\t\t\t\t\t\t...query,\n\t\t\t\t\t\t_fields: [\n\t\t\t\t\t\t\t...new Set( [\n\t\t\t\t\t\t\t\t...( getNormalizedCommaSeparable(\n\t\t\t\t\t\t\t\t\tquery._fields\n\t\t\t\t\t\t\t\t) || [] ),\n\t\t\t\t\t\t\t\tentityConfig.key || DEFAULT_ENTITY_KEY,\n\t\t\t\t\t\t\t] ),\n\t\t\t\t\t\t].join(),\n\t\t\t\t\t};\n\t\t\t\t}\n\n\t\t\t\t// Disable reason: While true that an early return could leave `path`\n\t\t\t\t// unused, it's important that path is derived using the query prior to\n\t\t\t\t// additional query modifications in the condition below, since those\n\t\t\t\t// modifications are relevant to how the data is tracked in state, and not\n\t\t\t\t// for how the request is made to the REST API.\n\n\t\t\t\t// eslint-disable-next-line @wordpress/no-unused-vars-before-return\n\t\t\t\tconst path = addQueryArgs(\n\t\t\t\t\tentityConfig.baseURL + ( key ? '/' + key : '' ),\n\t\t\t\t\t{\n\t\t\t\t\t\t...entityConfig.baseURLParams,\n\t\t\t\t\t\t...query,\n\t\t\t\t\t}\n\t\t\t\t);\n\n\t\t\t\tif ( query !== undefined && query._fields ) {\n\t\t\t\t\tquery = { ...query, include: [ key ] };\n\n\t\t\t\t\t// The resolution cache won't consider query as reusable based on the\n\t\t\t\t\t// fields, so it's tested here, prior to initiating the REST request,\n\t\t\t\t\t// and without causing `getEntityRecords` resolution to occur.\n\t\t\t\t\tconst hasRecords = select.hasEntityRecords(\n\t\t\t\t\t\tkind,\n\t\t\t\t\t\tname,\n\t\t\t\t\t\tquery\n\t\t\t\t\t);\n\t\t\t\t\tif ( hasRecords ) {\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tconst response = await apiFetch( { path, parse: false } );\n\t\t\t\tconst record = await response.json();\n\t\t\t\tconst permissions = getUserPermissionsFromAllowHeader(\n\t\t\t\t\tresponse.headers?.get( 'allow' )\n\t\t\t\t);\n\n\t\t\t\tconst canUserResolutionsArgs = [];\n\t\t\t\tconst receiveUserPermissionArgs = {};\n\t\t\t\tfor ( const action of ALLOWED_RESOURCE_ACTIONS ) {\n\t\t\t\t\treceiveUserPermissionArgs[\n\t\t\t\t\t\tgetUserPermissionCacheKey( action, {\n\t\t\t\t\t\t\tkind,\n\t\t\t\t\t\t\tname,\n\t\t\t\t\t\t\tid: key,\n\t\t\t\t\t\t} )\n\t\t\t\t\t] = permissions[ action ];\n\n\t\t\t\t\tcanUserResolutionsArgs.push( [\n\t\t\t\t\t\taction,\n\t\t\t\t\t\t{ kind, name, id: key },\n\t\t\t\t\t] );\n\t\t\t\t}\n\n\t\t\t\tregistry.batch( () => {\n\t\t\t\t\tdispatch.receiveEntityRecords( kind, name, record, query );\n\t\t\t\t\tdispatch.receiveUserPermissions(\n\t\t\t\t\t\treceiveUserPermissionArgs\n\t\t\t\t\t);\n\t\t\t\t\tdispatch.finishResolutions(\n\t\t\t\t\t\t'canUser',\n\t\t\t\t\t\tcanUserResolutionsArgs\n\t\t\t\t\t);\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\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, registry, resolveSelect } ) => {\n\t\tconst configs = await resolveSelect.getEntitiesConfig( 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 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\tconst key = entityConfig.key || DEFAULT_ENTITY_KEY;\n\n\t\tfunction getResolutionsArgs( records ) {\n\t\t\treturn records\n\t\t\t\t.filter( ( record ) => record?.[ key ] )\n\t\t\t\t.map( ( record ) => [ kind, name, record[ key ] ] );\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 = [],\n\t\t\t\tmeta;\n\t\t\tif ( entityConfig.supportsPagination && query.per_page !== -1 ) {\n\t\t\t\tconst response = await apiFetch( { path, parse: false } );\n\t\t\t\trecords = Object.values( await response.json() );\n\t\t\t\tmeta = {\n\t\t\t\t\ttotalItems: parseInt(\n\t\t\t\t\t\tresponse.headers.get( 'X-WP-Total' )\n\t\t\t\t\t),\n\t\t\t\t\ttotalPages: parseInt(\n\t\t\t\t\t\tresponse.headers.get( 'X-WP-TotalPages' )\n\t\t\t\t\t),\n\t\t\t\t};\n\t\t\t} else if (\n\t\t\t\tquery.per_page === -1 &&\n\t\t\t\tquery[ RECEIVE_INTERMEDIATE_RESULTS ] === true\n\t\t\t) {\n\t\t\t\tlet page = 1;\n\t\t\t\tlet totalPages;\n\n\t\t\t\tdo {\n\t\t\t\t\tconst response = await apiFetch( {\n\t\t\t\t\t\tpath: addQueryArgs( path, { page, per_page: 100 } ),\n\t\t\t\t\t\tparse: false,\n\t\t\t\t\t} );\n\t\t\t\t\tconst pageRecords = Object.values( await response.json() );\n\n\t\t\t\t\ttotalPages = parseInt(\n\t\t\t\t\t\tresponse.headers.get( 'X-WP-TotalPages' )\n\t\t\t\t\t);\n\n\t\t\t\t\trecords.push( ...pageRecords );\n\t\t\t\t\tregistry.batch( () => {\n\t\t\t\t\t\tdispatch.receiveEntityRecords(\n\t\t\t\t\t\t\tkind,\n\t\t\t\t\t\t\tname,\n\t\t\t\t\t\t\trecords,\n\t\t\t\t\t\t\tquery\n\t\t\t\t\t\t);\n\t\t\t\t\t\tdispatch.finishResolutions(\n\t\t\t\t\t\t\t'getEntityRecord',\n\t\t\t\t\t\t\tgetResolutionsArgs( pageRecords )\n\t\t\t\t\t\t);\n\t\t\t\t\t} );\n\t\t\t\t\tpage++;\n\t\t\t\t} while ( page <= totalPages );\n\n\t\t\t\tmeta = {\n\t\t\t\t\ttotalItems: records.length,\n\t\t\t\t\ttotalPages: 1,\n\t\t\t\t};\n\t\t\t} else {\n\t\t\t\trecords = Object.values( await apiFetch( { path } ) );\n\t\t\t\tmeta = {\n\t\t\t\t\ttotalItems: records.length,\n\t\t\t\t\ttotalPages: 1,\n\t\t\t\t};\n\t\t\t}\n\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 \"fulfilled\".\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\tregistry.batch( () => {\n\t\t\t\tdispatch.receiveEntityRecords(\n\t\t\t\t\tkind,\n\t\t\t\t\tname,\n\t\t\t\t\trecords,\n\t\t\t\t\tquery,\n\t\t\t\t\tfalse,\n\t\t\t\t\tundefined,\n\t\t\t\t\tmeta\n\t\t\t\t);\n\n\t\t\t\t// When requesting all fields, the list of results can be used to resolve\n\t\t\t\t// the `getEntityRecord` and `canUser` selectors in addition to `getEntityRecords`.\n\t\t\t\t// See https://github.com/WordPress/gutenberg/pull/26575\n\t\t\t\t// See https://github.com/WordPress/gutenberg/pull/64504\n\t\t\t\tif ( ! query?._fields && ! query.context ) {\n\t\t\t\t\tconst targetHints = records\n\t\t\t\t\t\t.filter( ( record ) => record?.[ key ] )\n\t\t\t\t\t\t.map( ( record ) => ( {\n\t\t\t\t\t\t\tid: record[ key ],\n\t\t\t\t\t\t\tpermissions: getUserPermissionsFromAllowHeader(\n\t\t\t\t\t\t\t\trecord?._links?.self?.[ 0 ].targetHints.allow\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t} ) );\n\n\t\t\t\t\tconst canUserResolutionsArgs = [];\n\t\t\t\t\tconst receiveUserPermissionArgs = {};\n\t\t\t\t\tfor ( const targetHint of targetHints ) {\n\t\t\t\t\t\tfor ( const action of ALLOWED_RESOURCE_ACTIONS ) {\n\t\t\t\t\t\t\tcanUserResolutionsArgs.push( [\n\t\t\t\t\t\t\t\taction,\n\t\t\t\t\t\t\t\t{ kind, name, id: targetHint.id },\n\t\t\t\t\t\t\t] );\n\n\t\t\t\t\t\t\treceiveUserPermissionArgs[\n\t\t\t\t\t\t\t\tgetUserPermissionCacheKey( action, {\n\t\t\t\t\t\t\t\t\tkind,\n\t\t\t\t\t\t\t\t\tname,\n\t\t\t\t\t\t\t\t\tid: targetHint.id,\n\t\t\t\t\t\t\t\t} )\n\t\t\t\t\t\t\t] = targetHint.permissions[ action ];\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\tdispatch.receiveUserPermissions(\n\t\t\t\t\t\treceiveUserPermissionArgs\n\t\t\t\t\t);\n\t\t\t\t\tdispatch.finishResolutions(\n\t\t\t\t\t\t'getEntityRecord',\n\t\t\t\t\t\tgetResolutionsArgs( records )\n\t\t\t\t\t);\n\t\t\t\t\tdispatch.finishResolutions(\n\t\t\t\t\t\t'canUser',\n\t\t\t\t\t\tcanUserResolutionsArgs\n\t\t\t\t\t);\n\t\t\t\t}\n\n\t\t\t\tdispatch.__unstableReleaseStoreLock( lock );\n\t\t\t} );\n\t\t} catch ( e ) {\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 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|Object} resource Entity resource to check. Accepts entity object `{ kind: 'root', name: 'media', id: 1 }`\n * or REST base as a string - `media`.\n * @param {?string} id ID of the rest resource to check.\n */\nexport const canUser =\n\t( requestedAction, resource, id ) =>\n\tasync ( { dispatch, registry, resolveSelect } ) => {\n\t\tif ( ! ALLOWED_RESOURCE_ACTIONS.includes( requestedAction ) ) {\n\t\t\tthrow new Error( `'${ requestedAction }' is not a valid action.` );\n\t\t}\n\n\t\tconst { hasStartedResolution } = registry.select( STORE_NAME );\n\n\t\t// Prevent resolving the same resource twice.\n\t\tfor ( const relatedAction of ALLOWED_RESOURCE_ACTIONS ) {\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 resourcePath = null;\n\t\tif ( typeof resource === 'object' ) {\n\t\t\tif ( ! resource.kind || ! resource.name ) {\n\t\t\t\tthrow new Error( 'The entity resource object is not valid.' );\n\t\t\t}\n\n\t\t\tconst configs = await resolveSelect.getEntitiesConfig(\n\t\t\t\tresource.kind\n\t\t\t);\n\t\t\tconst entityConfig = configs.find(\n\t\t\t\t( config ) =>\n\t\t\t\t\tconfig.name === resource.name &&\n\t\t\t\t\tconfig.kind === resource.kind\n\t\t\t);\n\t\t\tif ( ! entityConfig ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tresourcePath =\n\t\t\t\tentityConfig.baseURL + ( resource.id ? '/' + resource.id : '' );\n\t\t} else {\n\t\t\tresourcePath = `/wp/v2/${ resource }` + ( id ? '/' + id : '' );\n\t\t}\n\n\t\tlet response;\n\t\ttry {\n\t\t\tresponse = await apiFetch( {\n\t\t\t\tpath: 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 React native version. Instead, API requests\n\t\t// only return the result, without including response properties like the headers.\n\t\tconst permissions = getUserPermissionsFromAllowHeader(\n\t\t\tresponse.headers?.get( 'allow' )\n\t\t);\n\t\tregistry.batch( () => {\n\t\t\tfor ( const action of ALLOWED_RESOURCE_ACTIONS ) {\n\t\t\t\tconst key = getUserPermissionCacheKey( action, resource, id );\n\n\t\t\t\tdispatch.receiveUserPermission( key, permissions[ action ] );\n\n\t\t\t\t// Mark related action resolutions as finished.\n\t\t\t\tif ( action !== requestedAction ) {\n\t\t\t\t\tdispatch.finishResolution( 'canUser', [\n\t\t\t\t\t\taction,\n\t\t\t\t\t\tresource,\n\t\t\t\t\t\tid,\n\t\t\t\t\t] );\n\t\t\t\t}\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 {number|string} recordId Record's id.\n */\nexport const canUserEditEntityRecord =\n\t( kind, name, recordId ) =>\n\tasync ( { dispatch } ) => {\n\t\tawait dispatch( canUser( 'update', { kind, name, id: 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\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\treturn;\n\t\t}\n\n\t\t// Regex matches the ID at the end of a URL or immediately before\n\t\t// the query string.\n\t\tconst matches = globalStylesURL.match( /\\/(\\d+)(?:\\?|$)/ );\n\t\tconst id = matches ? Number( matches[ 1 ] ) : null;\n\n\t\tif ( id ) {\n\t\t\tdispatch.__experimentalReceiveCurrentGlobalStylesId( id );\n\t\t}\n\t};\n\nexport const __experimentalGetCurrentThemeBaseGlobalStyles =\n\t() =>\n\tasync ( { resolveSelect, dispatch } ) => {\n\t\tconst currentTheme = await resolveSelect.getCurrentTheme();\n\t\t// Please adjust the preloaded requests if this changes!\n\t\tconst themeGlobalStyles = await apiFetch( {\n\t\t\tpath: `/wp/v2/global-styles/themes/${ currentTheme.stylesheet }?context=view`,\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\t// Please adjust the preloaded requests if this changes!\n\t\tconst variations = await apiFetch( {\n\t\t\tpath: `/wp/v2/global-styles/themes/${ currentTheme.stylesheet }/variations?context=view`,\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 patterns = await fetchBlockPatterns();\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 getUserPatternCategories =\n\t() =>\n\tasync ( { dispatch, resolveSelect } ) => {\n\t\tconst patternCategories = await resolveSelect.getEntityRecords(\n\t\t\t'taxonomy',\n\t\t\t'wp_pattern_category',\n\t\t\t{\n\t\t\t\tper_page: -1,\n\t\t\t\t_fields: 'id,name,description,slug',\n\t\t\t\tcontext: 'view',\n\t\t\t}\n\t\t);\n\n\t\tconst mappedPatternCategories =\n\t\t\tpatternCategories?.map( ( userCategory ) => ( {\n\t\t\t\t...userCategory,\n\t\t\t\tlabel: decodeEntities( userCategory.name ),\n\t\t\t\tname: userCategory.slug,\n\t\t\t} ) ) || [];\n\n\t\tdispatch( {\n\t\t\ttype: 'RECEIVE_USER_PATTERN_CATEGORIES',\n\t\t\tpatternCategories: mappedPatternCategories,\n\t\t} );\n\t};\n\nexport const getNavigationFallbackId =\n\t() =>\n\tasync ( { dispatch, select, registry } ) => {\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\tregistry.batch( () => {\n\t\t\tdispatch.receiveNavigationFallbackId( fallback?.id );\n\n\t\t\tif ( ! record ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// If the fallback is already in the store, don't invalidate navigation queries.\n\t\t\t// Otherwise, invalidate the cache for the scenario where there were no Navigation\n\t\t\t// posts in the state and the fallback created one.\n\t\t\tconst existingFallbackEntityRecord = select.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\tconst invalidateNavigationQueries = ! existingFallbackEntityRecord;\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\tundefined,\n\t\t\t\tinvalidateNavigationQueries\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\nexport const getDefaultTemplateId =\n\t( query ) =>\n\tasync ( { dispatch, registry, resolveSelect } ) => {\n\t\tconst template = await apiFetch( {\n\t\t\tpath: addQueryArgs( '/wp/v2/templates/lookup', query ),\n\t\t} );\n\t\t// Wait for the the entities config to be loaded, otherwise receiving\n\t\t// the template as an entity will not work.\n\t\tawait resolveSelect.getEntitiesConfig( 'postType' );\n\t\t// Endpoint may return an empty object if no template is found.\n\t\tif ( template?.id ) {\n\t\t\tregistry.batch( () => {\n\t\t\t\tdispatch.receiveDefaultTemplateId( query, template.id );\n\t\t\t\tdispatch.receiveEntityRecords( 'postType', 'wp_template', [\n\t\t\t\t\ttemplate,\n\t\t\t\t] );\n\t\t\t\t// Avoid further network requests.\n\t\t\t\tdispatch.finishResolution( 'getEntityRecord', [\n\t\t\t\t\t'postType',\n\t\t\t\t\t'wp_template',\n\t\t\t\t\ttemplate.id,\n\t\t\t\t] );\n\t\t\t} );\n\t\t}\n\t};\n\n/**\n * Requests an entity's revisions from the REST API.\n *\n * @param {string} kind Entity kind.\n * @param {string} name Entity name.\n * @param {number|string} recordKey The key of the entity record whose revisions you want to fetch.\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 getRevisions =\n\t( kind, name, recordKey, query = {} ) =>\n\tasync ( { dispatch, registry, resolveSelect } ) => {\n\t\tconst configs = await resolveSelect.getEntitiesConfig( kind );\n\t\tconst entityConfig = configs.find(\n\t\t\t( config ) => config.name === name && config.kind === kind\n\t\t);\n\n\t\tif ( ! entityConfig ) {\n\t\t\treturn;\n\t\t}\n\n\t\tif ( query._fields ) {\n\t\t\t// If requesting specific fields, items and query association to said\n\t\t\t// records are stored by ID reference. Thus, fields must always include\n\t\t\t// the ID.\n\t\t\tquery = {\n\t\t\t\t...query,\n\t\t\t\t_fields: [\n\t\t\t\t\t...new Set( [\n\t\t\t\t\t\t...( getNormalizedCommaSeparable( query._fields ) ||\n\t\t\t\t\t\t\t[] ),\n\t\t\t\t\t\tentityConfig.revisionKey || DEFAULT_ENTITY_KEY,\n\t\t\t\t\t] ),\n\t\t\t\t].join(),\n\t\t\t};\n\t\t}\n\n\t\tconst path = addQueryArgs(\n\t\t\tentityConfig.getRevisionsUrl( recordKey ),\n\t\t\tquery\n\t\t);\n\n\t\tlet records, response;\n\t\tconst meta = {};\n\t\tconst isPaginated =\n\t\t\tentityConfig.supportsPagination && query.per_page !== -1;\n\t\ttry {\n\t\t\tresponse = await apiFetch( { path, parse: ! isPaginated } );\n\t\t} catch ( error ) {\n\t\t\t// Do nothing if our request comes back with an API error.\n\t\t\treturn;\n\t\t}\n\n\t\tif ( response ) {\n\t\t\tif ( isPaginated ) {\n\t\t\t\trecords = Object.values( await response.json() );\n\t\t\t\tmeta.totalItems = parseInt(\n\t\t\t\t\tresponse.headers.get( 'X-WP-Total' )\n\t\t\t\t);\n\t\t\t} else {\n\t\t\t\trecords = Object.values( response );\n\t\t\t}\n\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 \"fulfilled\".\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\tregistry.batch( () => {\n\t\t\t\tdispatch.receiveRevisions(\n\t\t\t\t\tkind,\n\t\t\t\t\tname,\n\t\t\t\t\trecordKey,\n\t\t\t\t\trecords,\n\t\t\t\t\tquery,\n\t\t\t\t\tfalse,\n\t\t\t\t\tmeta\n\t\t\t\t);\n\n\t\t\t\t// When requesting all fields, the list of results can be used to\n\t\t\t\t// resolve the `getRevision` selector in addition to `getRevisions`.\n\t\t\t\tif ( ! query?._fields && ! query.context ) {\n\t\t\t\t\tconst key = entityConfig.key || DEFAULT_ENTITY_KEY;\n\t\t\t\t\tconst resolutionsArgs = records\n\t\t\t\t\t\t.filter( ( record ) => record[ key ] )\n\t\t\t\t\t\t.map( ( record ) => [\n\t\t\t\t\t\t\tkind,\n\t\t\t\t\t\t\tname,\n\t\t\t\t\t\t\trecordKey,\n\t\t\t\t\t\t\trecord[ key ],\n\t\t\t\t\t\t] );\n\n\t\t\t\t\tdispatch.finishResolutions(\n\t\t\t\t\t\t'getRevision',\n\t\t\t\t\t\tresolutionsArgs\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t} );\n\t\t}\n\t};\n\n// Invalidate cache when a new revision is created.\ngetRevisions.shouldInvalidate = ( action, kind, name, recordKey ) =>\n\taction.type === 'SAVE_ENTITY_RECORD_FINISH' &&\n\tname === action.name &&\n\tkind === action.kind &&\n\t! action.error &&\n\trecordKey === action.recordId;\n\n/**\n * Requests a specific Entity revision from the REST API.\n *\n * @param {string} kind Entity kind.\n * @param {string} name Entity name.\n * @param {number|string} recordKey The key of the entity record whose revisions you want to fetch.\n * @param {number|string} revisionKey The revision'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 getRevision =\n\t( kind, name, recordKey, revisionKey, query ) =>\n\tasync ( { dispatch, resolveSelect } ) => {\n\t\tconst configs = await resolveSelect.getEntitiesConfig( kind );\n\t\tconst entityConfig = configs.find(\n\t\t\t( config ) => config.name === name && config.kind === kind\n\t\t);\n\n\t\tif ( ! entityConfig ) {\n\t\t\treturn;\n\t\t}\n\n\t\tif ( query !== undefined && query._fields ) {\n\t\t\t// If requesting specific fields, items and query association to said\n\t\t\t// records are stored by ID reference. Thus, fields must always include\n\t\t\t// the ID.\n\t\t\tquery = {\n\t\t\t\t...query,\n\t\t\t\t_fields: [\n\t\t\t\t\t...new Set( [\n\t\t\t\t\t\t...( getNormalizedCommaSeparable( query._fields ) ||\n\t\t\t\t\t\t\t[] ),\n\t\t\t\t\t\tentityConfig.revisionKey || DEFAULT_ENTITY_KEY,\n\t\t\t\t\t] ),\n\t\t\t\t].join(),\n\t\t\t};\n\t\t}\n\t\tconst path = addQueryArgs(\n\t\t\tentityConfig.getRevisionsUrl( recordKey, revisionKey ),\n\t\t\tquery\n\t\t);\n\n\t\tlet record;\n\t\ttry {\n\t\t\trecord = await apiFetch( { path } );\n\t\t} catch ( error ) {\n\t\t\t// Do nothing if our request comes back with an API error.\n\t\t\treturn;\n\t\t}\n\n\t\tif ( record ) {\n\t\t\tdispatch.receiveRevisions( kind, name, recordKey, record, query );\n\t\t}\n\t};\n\n/**\n * Requests a specific post type options from the REST API.\n *\n * @param {string} postType Post type slug.\n */\nexport const getRegisteredPostMeta =\n\t( postType ) =>\n\tasync ( { dispatch, resolveSelect } ) => {\n\t\tlet options;\n\t\ttry {\n\t\t\tconst {\n\t\t\t\trest_namespace: restNamespace = 'wp/v2',\n\t\t\t\trest_base: restBase,\n\t\t\t} = ( await resolveSelect.getPostType( postType ) ) || {};\n\t\t\toptions = await apiFetch( {\n\t\t\t\tpath: `${ restNamespace }/${ restBase }/?context=edit`,\n\t\t\t\tmethod: 'OPTIONS',\n\t\t\t} );\n\t\t} catch ( error ) {\n\t\t\t// Do nothing if the request comes back with an API error.\n\t\t\treturn;\n\t\t}\n\n\t\tif ( options ) {\n\t\t\tdispatch.receiveRegisteredPostMeta(\n\t\t\t\tpostType,\n\t\t\t\toptions?.schema?.properties?.meta?.properties\n\t\t\t);\n\t\t}\n\t};\n\n/**\n * Requests entity configs for the given kind from the REST API.\n *\n * @param {string} kind Entity kind.\n */\nexport const getEntitiesConfig =\n\t( kind ) =>\n\tasync ( { dispatch } ) => {\n\t\tconst loader = additionalEntityConfigLoaders.find(\n\t\t\t( l ) => l.kind === kind\n\t\t);\n\n\t\tif ( ! loader ) {\n\t\t\treturn;\n\t\t}\n\n\t\ttry {\n\t\t\tconst configs = await loader.loadEntities();\n\t\t\tif ( ! configs.length ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tdispatch.addEntities( configs );\n\t\t} catch {\n\t\t\t// Do nothing if the request comes back with an API error.\n\t\t}\n\t};\n"],"mappings":";;;;;;;;AAGA,IAAAA,WAAA,GAAAC,OAAA;AAKA,IAAAC,IAAA,GAAAD,OAAA;AACA,IAAAE,aAAA,GAAAF,OAAA;AACA,IAAAG,SAAA,GAAAC,sBAAA,CAAAJ,OAAA;AAKA,IAAAK,KAAA,GAAAL,OAAA;AACA,IAAAM,SAAA,GAAAN,OAAA;AACA,IAAAO,MAAA,GAAAP,OAAA;AAQA,IAAAQ,KAAA,GAAAR,OAAA;AACA,IAAAS,MAAA,GAAAT,OAAA;AA1BA;AACA;AACA;;AAGA;AACA;AACA;;AAKA;AACA;AACA;;AAcA;AACA;AACA;AACA;AACA;AACA;AACO,MAAMU,UAAU,GACpBC,KAAK,IACP,OAAQ;EAAEC;AAAS,CAAC,KAAM;EACzB,MAAMC,IAAI,GAAG,IAAAC,iBAAY,EACxB,wCAAwC,EACxCH,KACD,CAAC;EACD,MAAMI,KAAK,GAAG,MAAM,IAAAC,iBAAQ,EAAE;IAAEH;EAAK,CAAE,CAAC;EACxCD,QAAQ,CAACK,gBAAgB,CAAEJ,IAAI,EAAEE,KAAM,CAAC;AACzC,CAAC;;AAEF;AACA;AACA;AAFAG,OAAA,CAAAR,UAAA,GAAAA,UAAA;AAGO,MAAMS,cAAc,GAC1BA,CAAA,KACA,OAAQ;EAAEP;AAAS,CAAC,KAAM;EACzB,MAAMQ,WAAW,GAAG,MAAM,IAAAJ,iBAAQ,EAAE;IAAEH,IAAI,EAAE;EAAkB,CAAE,CAAC;EACjED,QAAQ,CA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oreList":[]}
1
+ {"version":3,"names":["_changeCase","require","_url","_htmlEntities","_apiFetch","_interopRequireDefault","_name","_entities","_utils","_sync","_fetch","getAuthors","query","dispatch","path","addQueryArgs","users","apiFetch","receiveUserQuery","exports","getCurrentUser","currentUser","receiveCurrentUser","getEntityRecord","kind","name","key","select","registry","resolveSelect","configs","getEntitiesConfig","entityConfig","find","config","lock","__unstableAcquireStoreLock","STORE_NAME","exclusive","window","__experimentalEnableSync","syncConfig","globalThis","IS_GUTENBERG_PLUGIN","objectId","getSyncObjectId","getSyncProvider","bootstrap","syncObjectType","record","receiveEntityRecords","type","recordId","edits","meta","undo","undefined","_fields","Set","getNormalizedCommaSeparable","DEFAULT_ENTITY_KEY","join","baseURL","baseURLParams","include","hasRecords","hasEntityRecords","response","parse","json","permissions","getUserPermissionsFromAllowHeader","headers","get","canUserResolutionsArgs","receiveUserPermissionArgs","action","ALLOWED_RESOURCE_ACTIONS","getUserPermissionCacheKey","id","push","batch","receiveUserPermissions","finishResolutions","__unstableReleaseStoreLock","getRawEntityRecord","forwardResolver","getEditedEntityRecord","getEntityRecords","getResolutionsArgs","records","filter","map","supportsPagination","per_page","Object","values","totalItems","parseInt","totalPages","RECEIVE_INTERMEDIATE_RESULTS","page","pageRecords","length","split","forEach","field","hasOwnProperty","context","targetHints","_links","self","allow","targetHint","e","shouldInvalidate","invalidateCache","getCurrentTheme","activeThemes","status","receiveCurrentTheme","getThemeSupports","getEmbedPreview","url","embedProxyResponse","receiveEmbedPreview","error","canUser","requestedAction","resource","includes","Error","hasStartedResolution","relatedAction","isAlreadyResolving","resourcePath","method","receiveUserPermission","finishResolution","canUserEditEntityRecord","getAutosaves","postType","postId","rest_base","restBase","rest_namespace","restNamespace","getPostType","autosaves","receiveAutosaves","getAutosave","__experimentalGetCurrentGlobalStylesId","globalStylesURL","href","matches","match","Number","__experimentalReceiveCurrentGlobalStylesId","__experimentalGetCurrentThemeBaseGlobalStyles","currentTheme","themeGlobalStyles","stylesheet","__experimentalReceiveThemeBaseGlobalStyles","__experimentalGetCurrentThemeGlobalStylesVariations","variations","__experimentalReceiveThemeGlobalStyleVariations","getCurrentThemeGlobalStylesRevisions","globalStylesId","revisionsURL","resetRevisions","revisions","revision","fromEntries","entries","value","camelCase","receiveThemeGlobalStyleRevisions","getBlockPatterns","patterns","fetchBlockPatterns","getBlockPatternCategories","categories","getUserPatternCategories","patternCategories","mappedPatternCategories","userCategory","label","decodeEntities","slug","getNavigationFallbackId","fallback","_embed","_embedded","receiveNavigationFallbackId","existingFallbackEntityRecord","invalidateNavigationQueries","getDefaultTemplateId","template","receiveDefaultTemplateId","getRevisions","recordKey","revisionKey","getRevisionsUrl","isPaginated","receiveRevisions","resolutionsArgs","getRevision","getRegisteredPostMeta","options","receiveRegisteredPostMeta","schema","properties","loader","additionalEntityConfigLoaders","l","loadEntities","addEntities"],"sources":["@wordpress/core-data/src/resolvers.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport { camelCase } from 'change-case';\n\n/**\n * WordPress dependencies\n */\nimport { addQueryArgs } from '@wordpress/url';\nimport { decodeEntities } from '@wordpress/html-entities';\nimport apiFetch from '@wordpress/api-fetch';\n\n/**\n * Internal dependencies\n */\nimport { STORE_NAME } from './name';\nimport { additionalEntityConfigLoaders, DEFAULT_ENTITY_KEY } from './entities';\nimport {\n\tforwardResolver,\n\tgetNormalizedCommaSeparable,\n\tgetUserPermissionCacheKey,\n\tgetUserPermissionsFromAllowHeader,\n\tALLOWED_RESOURCE_ACTIONS,\n\tRECEIVE_INTERMEDIATE_RESULTS,\n} from './utils';\nimport { getSyncProvider } from './sync';\nimport { fetchBlockPatterns } from './fetch';\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, registry, resolveSelect } ) => {\n\t\tconst configs = await resolveSelect.getEntitiesConfig( 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 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\t// Entity supports configs,\n\t\t\t// use the sync algorithm instead of the old fetch behavior.\n\t\t\tif (\n\t\t\t\twindow.__experimentalEnableSync &&\n\t\t\t\tentityConfig.syncConfig &&\n\t\t\t\t! query\n\t\t\t) {\n\t\t\t\tif ( globalThis.IS_GUTENBERG_PLUGIN ) {\n\t\t\t\t\tconst objectId = entityConfig.getSyncObjectId( key );\n\n\t\t\t\t\t// Loads the persisted document.\n\t\t\t\t\tawait getSyncProvider().bootstrap(\n\t\t\t\t\t\tentityConfig.syncObjectType,\n\t\t\t\t\t\tobjectId,\n\t\t\t\t\t\t( record ) => {\n\t\t\t\t\t\t\tdispatch.receiveEntityRecords(\n\t\t\t\t\t\t\t\tkind,\n\t\t\t\t\t\t\t\tname,\n\t\t\t\t\t\t\t\trecord,\n\t\t\t\t\t\t\t\tquery\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}\n\t\t\t\t\t);\n\n\t\t\t\t\t// Boostraps the edited document as well (and load from peers).\n\t\t\t\t\tawait getSyncProvider().bootstrap(\n\t\t\t\t\t\tentityConfig.syncObjectType + '--edit',\n\t\t\t\t\t\tobjectId,\n\t\t\t\t\t\t( record ) => {\n\t\t\t\t\t\t\tdispatch( {\n\t\t\t\t\t\t\t\ttype: 'EDIT_ENTITY_RECORD',\n\t\t\t\t\t\t\t\tkind,\n\t\t\t\t\t\t\t\tname,\n\t\t\t\t\t\t\t\trecordId: key,\n\t\t\t\t\t\t\t\tedits: record,\n\t\t\t\t\t\t\t\tmeta: {\n\t\t\t\t\t\t\t\t\tundo: undefined,\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t} );\n\t\t\t\t\t\t}\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tif ( query !== undefined && query._fields ) {\n\t\t\t\t\t// If requesting specific fields, items and query association to said\n\t\t\t\t\t// records are stored by ID reference. Thus, fields must always include\n\t\t\t\t\t// the ID.\n\t\t\t\t\tquery = {\n\t\t\t\t\t\t...query,\n\t\t\t\t\t\t_fields: [\n\t\t\t\t\t\t\t...new Set( [\n\t\t\t\t\t\t\t\t...( getNormalizedCommaSeparable(\n\t\t\t\t\t\t\t\t\tquery._fields\n\t\t\t\t\t\t\t\t) || [] ),\n\t\t\t\t\t\t\t\tentityConfig.key || DEFAULT_ENTITY_KEY,\n\t\t\t\t\t\t\t] ),\n\t\t\t\t\t\t].join(),\n\t\t\t\t\t};\n\t\t\t\t}\n\n\t\t\t\t// Disable reason: While true that an early return could leave `path`\n\t\t\t\t// unused, it's important that path is derived using the query prior to\n\t\t\t\t// additional query modifications in the condition below, since those\n\t\t\t\t// modifications are relevant to how the data is tracked in state, and not\n\t\t\t\t// for how the request is made to the REST API.\n\n\t\t\t\t// eslint-disable-next-line @wordpress/no-unused-vars-before-return\n\t\t\t\tconst path = addQueryArgs(\n\t\t\t\t\tentityConfig.baseURL + ( key ? '/' + key : '' ),\n\t\t\t\t\t{\n\t\t\t\t\t\t...entityConfig.baseURLParams,\n\t\t\t\t\t\t...query,\n\t\t\t\t\t}\n\t\t\t\t);\n\n\t\t\t\tif ( query !== undefined && query._fields ) {\n\t\t\t\t\tquery = { ...query, include: [ key ] };\n\n\t\t\t\t\t// The resolution cache won't consider query as reusable based on the\n\t\t\t\t\t// fields, so it's tested here, prior to initiating the REST request,\n\t\t\t\t\t// and without causing `getEntityRecords` resolution to occur.\n\t\t\t\t\tconst hasRecords = select.hasEntityRecords(\n\t\t\t\t\t\tkind,\n\t\t\t\t\t\tname,\n\t\t\t\t\t\tquery\n\t\t\t\t\t);\n\t\t\t\t\tif ( hasRecords ) {\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tconst response = await apiFetch( { path, parse: false } );\n\t\t\t\tconst record = await response.json();\n\t\t\t\tconst permissions = getUserPermissionsFromAllowHeader(\n\t\t\t\t\tresponse.headers?.get( 'allow' )\n\t\t\t\t);\n\n\t\t\t\tconst canUserResolutionsArgs = [];\n\t\t\t\tconst receiveUserPermissionArgs = {};\n\t\t\t\tfor ( const action of ALLOWED_RESOURCE_ACTIONS ) {\n\t\t\t\t\treceiveUserPermissionArgs[\n\t\t\t\t\t\tgetUserPermissionCacheKey( action, {\n\t\t\t\t\t\t\tkind,\n\t\t\t\t\t\t\tname,\n\t\t\t\t\t\t\tid: key,\n\t\t\t\t\t\t} )\n\t\t\t\t\t] = permissions[ action ];\n\n\t\t\t\t\tcanUserResolutionsArgs.push( [\n\t\t\t\t\t\taction,\n\t\t\t\t\t\t{ kind, name, id: key },\n\t\t\t\t\t] );\n\t\t\t\t}\n\n\t\t\t\tregistry.batch( () => {\n\t\t\t\t\tdispatch.receiveEntityRecords( kind, name, record, query );\n\t\t\t\t\tdispatch.receiveUserPermissions(\n\t\t\t\t\t\treceiveUserPermissionArgs\n\t\t\t\t\t);\n\t\t\t\t\tdispatch.finishResolutions(\n\t\t\t\t\t\t'canUser',\n\t\t\t\t\t\tcanUserResolutionsArgs\n\t\t\t\t\t);\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\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, registry, resolveSelect } ) => {\n\t\tconst configs = await resolveSelect.getEntitiesConfig( 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 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\tconst key = entityConfig.key || DEFAULT_ENTITY_KEY;\n\n\t\tfunction getResolutionsArgs( records ) {\n\t\t\treturn records\n\t\t\t\t.filter( ( record ) => record?.[ key ] )\n\t\t\t\t.map( ( record ) => [ kind, name, record[ key ] ] );\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 = [],\n\t\t\t\tmeta;\n\t\t\tif ( entityConfig.supportsPagination && query.per_page !== -1 ) {\n\t\t\t\tconst response = await apiFetch( { path, parse: false } );\n\t\t\t\trecords = Object.values( await response.json() );\n\t\t\t\tmeta = {\n\t\t\t\t\ttotalItems: parseInt(\n\t\t\t\t\t\tresponse.headers.get( 'X-WP-Total' )\n\t\t\t\t\t),\n\t\t\t\t\ttotalPages: parseInt(\n\t\t\t\t\t\tresponse.headers.get( 'X-WP-TotalPages' )\n\t\t\t\t\t),\n\t\t\t\t};\n\t\t\t} else if (\n\t\t\t\tquery.per_page === -1 &&\n\t\t\t\tquery[ RECEIVE_INTERMEDIATE_RESULTS ] === true\n\t\t\t) {\n\t\t\t\tlet page = 1;\n\t\t\t\tlet totalPages;\n\n\t\t\t\tdo {\n\t\t\t\t\tconst response = await apiFetch( {\n\t\t\t\t\t\tpath: addQueryArgs( path, { page, per_page: 100 } ),\n\t\t\t\t\t\tparse: false,\n\t\t\t\t\t} );\n\t\t\t\t\tconst pageRecords = Object.values( await response.json() );\n\n\t\t\t\t\ttotalPages = parseInt(\n\t\t\t\t\t\tresponse.headers.get( 'X-WP-TotalPages' )\n\t\t\t\t\t);\n\n\t\t\t\t\trecords.push( ...pageRecords );\n\t\t\t\t\tregistry.batch( () => {\n\t\t\t\t\t\tdispatch.receiveEntityRecords(\n\t\t\t\t\t\t\tkind,\n\t\t\t\t\t\t\tname,\n\t\t\t\t\t\t\trecords,\n\t\t\t\t\t\t\tquery\n\t\t\t\t\t\t);\n\t\t\t\t\t\tdispatch.finishResolutions(\n\t\t\t\t\t\t\t'getEntityRecord',\n\t\t\t\t\t\t\tgetResolutionsArgs( pageRecords )\n\t\t\t\t\t\t);\n\t\t\t\t\t} );\n\t\t\t\t\tpage++;\n\t\t\t\t} while ( page <= totalPages );\n\n\t\t\t\tmeta = {\n\t\t\t\t\ttotalItems: records.length,\n\t\t\t\t\ttotalPages: 1,\n\t\t\t\t};\n\t\t\t} else {\n\t\t\t\trecords = Object.values( await apiFetch( { path } ) );\n\t\t\t\tmeta = {\n\t\t\t\t\ttotalItems: records.length,\n\t\t\t\t\ttotalPages: 1,\n\t\t\t\t};\n\t\t\t}\n\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 \"fulfilled\".\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\tregistry.batch( () => {\n\t\t\t\tdispatch.receiveEntityRecords(\n\t\t\t\t\tkind,\n\t\t\t\t\tname,\n\t\t\t\t\trecords,\n\t\t\t\t\tquery,\n\t\t\t\t\tfalse,\n\t\t\t\t\tundefined,\n\t\t\t\t\tmeta\n\t\t\t\t);\n\n\t\t\t\t// When requesting all fields, the list of results can be used to resolve\n\t\t\t\t// the `getEntityRecord` and `canUser` selectors in addition to `getEntityRecords`.\n\t\t\t\t// See https://github.com/WordPress/gutenberg/pull/26575\n\t\t\t\t// See https://github.com/WordPress/gutenberg/pull/64504\n\t\t\t\tif ( ! query?._fields && ! query.context ) {\n\t\t\t\t\tconst targetHints = records\n\t\t\t\t\t\t.filter( ( record ) => record?.[ key ] )\n\t\t\t\t\t\t.map( ( record ) => ( {\n\t\t\t\t\t\t\tid: record[ key ],\n\t\t\t\t\t\t\tpermissions: getUserPermissionsFromAllowHeader(\n\t\t\t\t\t\t\t\trecord?._links?.self?.[ 0 ].targetHints.allow\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t} ) );\n\n\t\t\t\t\tconst canUserResolutionsArgs = [];\n\t\t\t\t\tconst receiveUserPermissionArgs = {};\n\t\t\t\t\tfor ( const targetHint of targetHints ) {\n\t\t\t\t\t\tfor ( const action of ALLOWED_RESOURCE_ACTIONS ) {\n\t\t\t\t\t\t\tcanUserResolutionsArgs.push( [\n\t\t\t\t\t\t\t\taction,\n\t\t\t\t\t\t\t\t{ kind, name, id: targetHint.id },\n\t\t\t\t\t\t\t] );\n\n\t\t\t\t\t\t\treceiveUserPermissionArgs[\n\t\t\t\t\t\t\t\tgetUserPermissionCacheKey( action, {\n\t\t\t\t\t\t\t\t\tkind,\n\t\t\t\t\t\t\t\t\tname,\n\t\t\t\t\t\t\t\t\tid: targetHint.id,\n\t\t\t\t\t\t\t\t} )\n\t\t\t\t\t\t\t] = targetHint.permissions[ action ];\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\tdispatch.receiveUserPermissions(\n\t\t\t\t\t\treceiveUserPermissionArgs\n\t\t\t\t\t);\n\t\t\t\t\tdispatch.finishResolutions(\n\t\t\t\t\t\t'getEntityRecord',\n\t\t\t\t\t\tgetResolutionsArgs( records )\n\t\t\t\t\t);\n\t\t\t\t\tdispatch.finishResolutions(\n\t\t\t\t\t\t'canUser',\n\t\t\t\t\t\tcanUserResolutionsArgs\n\t\t\t\t\t);\n\t\t\t\t}\n\n\t\t\t\tdispatch.__unstableReleaseStoreLock( lock );\n\t\t\t} );\n\t\t} catch ( e ) {\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 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|Object} resource Entity resource to check. Accepts entity object `{ kind: 'root', name: 'media', id: 1 }`\n * or REST base as a string - `media`.\n * @param {?string} id ID of the rest resource to check.\n */\nexport const canUser =\n\t( requestedAction, resource, id ) =>\n\tasync ( { dispatch, registry, resolveSelect } ) => {\n\t\tif ( ! ALLOWED_RESOURCE_ACTIONS.includes( requestedAction ) ) {\n\t\t\tthrow new Error( `'${ requestedAction }' is not a valid action.` );\n\t\t}\n\n\t\tconst { hasStartedResolution } = registry.select( STORE_NAME );\n\n\t\t// Prevent resolving the same resource twice.\n\t\tfor ( const relatedAction of ALLOWED_RESOURCE_ACTIONS ) {\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 resourcePath = null;\n\t\tif ( typeof resource === 'object' ) {\n\t\t\tif ( ! resource.kind || ! resource.name ) {\n\t\t\t\tthrow new Error( 'The entity resource object is not valid.' );\n\t\t\t}\n\n\t\t\tconst configs = await resolveSelect.getEntitiesConfig(\n\t\t\t\tresource.kind\n\t\t\t);\n\t\t\tconst entityConfig = configs.find(\n\t\t\t\t( config ) =>\n\t\t\t\t\tconfig.name === resource.name &&\n\t\t\t\t\tconfig.kind === resource.kind\n\t\t\t);\n\t\t\tif ( ! entityConfig ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tresourcePath =\n\t\t\t\tentityConfig.baseURL + ( resource.id ? '/' + resource.id : '' );\n\t\t} else {\n\t\t\tresourcePath = `/wp/v2/${ resource }` + ( id ? '/' + id : '' );\n\t\t}\n\n\t\tlet response;\n\t\ttry {\n\t\t\tresponse = await apiFetch( {\n\t\t\t\tpath: 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 React native version. Instead, API requests\n\t\t// only return the result, without including response properties like the headers.\n\t\tconst permissions = getUserPermissionsFromAllowHeader(\n\t\t\tresponse.headers?.get( 'allow' )\n\t\t);\n\t\tregistry.batch( () => {\n\t\t\tfor ( const action of ALLOWED_RESOURCE_ACTIONS ) {\n\t\t\t\tconst key = getUserPermissionCacheKey( action, resource, id );\n\n\t\t\t\tdispatch.receiveUserPermission( key, permissions[ action ] );\n\n\t\t\t\t// Mark related action resolutions as finished.\n\t\t\t\tif ( action !== requestedAction ) {\n\t\t\t\t\tdispatch.finishResolution( 'canUser', [\n\t\t\t\t\t\taction,\n\t\t\t\t\t\tresource,\n\t\t\t\t\t\tid,\n\t\t\t\t\t] );\n\t\t\t\t}\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 {number|string} recordId Record's id.\n */\nexport const canUserEditEntityRecord =\n\t( kind, name, recordId ) =>\n\tasync ( { dispatch } ) => {\n\t\tawait dispatch( canUser( 'update', { kind, name, id: 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\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\treturn;\n\t\t}\n\n\t\t// Regex matches the ID at the end of a URL or immediately before\n\t\t// the query string.\n\t\tconst matches = globalStylesURL.match( /\\/(\\d+)(?:\\?|$)/ );\n\t\tconst id = matches ? Number( matches[ 1 ] ) : null;\n\n\t\tif ( id ) {\n\t\t\tdispatch.__experimentalReceiveCurrentGlobalStylesId( id );\n\t\t}\n\t};\n\nexport const __experimentalGetCurrentThemeBaseGlobalStyles =\n\t() =>\n\tasync ( { resolveSelect, dispatch } ) => {\n\t\tconst currentTheme = await resolveSelect.getCurrentTheme();\n\t\t// Please adjust the preloaded requests if this changes!\n\t\tconst themeGlobalStyles = await apiFetch( {\n\t\t\tpath: `/wp/v2/global-styles/themes/${ currentTheme.stylesheet }?context=view`,\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\t// Please adjust the preloaded requests if this changes!\n\t\tconst variations = await apiFetch( {\n\t\t\tpath: `/wp/v2/global-styles/themes/${ currentTheme.stylesheet }/variations?context=view`,\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 patterns = await fetchBlockPatterns();\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 getUserPatternCategories =\n\t() =>\n\tasync ( { dispatch, resolveSelect } ) => {\n\t\tconst patternCategories = await resolveSelect.getEntityRecords(\n\t\t\t'taxonomy',\n\t\t\t'wp_pattern_category',\n\t\t\t{\n\t\t\t\tper_page: -1,\n\t\t\t\t_fields: 'id,name,description,slug',\n\t\t\t\tcontext: 'view',\n\t\t\t}\n\t\t);\n\n\t\tconst mappedPatternCategories =\n\t\t\tpatternCategories?.map( ( userCategory ) => ( {\n\t\t\t\t...userCategory,\n\t\t\t\tlabel: decodeEntities( userCategory.name ),\n\t\t\t\tname: userCategory.slug,\n\t\t\t} ) ) || [];\n\n\t\tdispatch( {\n\t\t\ttype: 'RECEIVE_USER_PATTERN_CATEGORIES',\n\t\t\tpatternCategories: mappedPatternCategories,\n\t\t} );\n\t};\n\nexport const getNavigationFallbackId =\n\t() =>\n\tasync ( { dispatch, select, registry } ) => {\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\tregistry.batch( () => {\n\t\t\tdispatch.receiveNavigationFallbackId( fallback?.id );\n\n\t\t\tif ( ! record ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// If the fallback is already in the store, don't invalidate navigation queries.\n\t\t\t// Otherwise, invalidate the cache for the scenario where there were no Navigation\n\t\t\t// posts in the state and the fallback created one.\n\t\t\tconst existingFallbackEntityRecord = select.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\tconst invalidateNavigationQueries = ! existingFallbackEntityRecord;\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\tundefined,\n\t\t\t\tinvalidateNavigationQueries\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\nexport const getDefaultTemplateId =\n\t( query ) =>\n\tasync ( { dispatch, registry, resolveSelect } ) => {\n\t\tconst template = await apiFetch( {\n\t\t\tpath: addQueryArgs( '/wp/v2/templates/lookup', query ),\n\t\t} );\n\t\t// Wait for the the entities config to be loaded, otherwise receiving\n\t\t// the template as an entity will not work.\n\t\tawait resolveSelect.getEntitiesConfig( 'postType' );\n\t\t// Endpoint may return an empty object if no template is found.\n\t\tif ( template?.id ) {\n\t\t\tregistry.batch( () => {\n\t\t\t\tdispatch.receiveDefaultTemplateId( query, template.id );\n\t\t\t\tdispatch.receiveEntityRecords( 'postType', 'wp_template', [\n\t\t\t\t\ttemplate,\n\t\t\t\t] );\n\t\t\t\t// Avoid further network requests.\n\t\t\t\tdispatch.finishResolution( 'getEntityRecord', [\n\t\t\t\t\t'postType',\n\t\t\t\t\t'wp_template',\n\t\t\t\t\ttemplate.id,\n\t\t\t\t] );\n\t\t\t} );\n\t\t}\n\t};\n\n/**\n * Requests an entity's revisions from the REST API.\n *\n * @param {string} kind Entity kind.\n * @param {string} name Entity name.\n * @param {number|string} recordKey The key of the entity record whose revisions you want to fetch.\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 getRevisions =\n\t( kind, name, recordKey, query = {} ) =>\n\tasync ( { dispatch, registry, resolveSelect } ) => {\n\t\tconst configs = await resolveSelect.getEntitiesConfig( kind );\n\t\tconst entityConfig = configs.find(\n\t\t\t( config ) => config.name === name && config.kind === kind\n\t\t);\n\n\t\tif ( ! entityConfig ) {\n\t\t\treturn;\n\t\t}\n\n\t\tif ( query._fields ) {\n\t\t\t// If requesting specific fields, items and query association to said\n\t\t\t// records are stored by ID reference. Thus, fields must always include\n\t\t\t// the ID.\n\t\t\tquery = {\n\t\t\t\t...query,\n\t\t\t\t_fields: [\n\t\t\t\t\t...new Set( [\n\t\t\t\t\t\t...( getNormalizedCommaSeparable( query._fields ) ||\n\t\t\t\t\t\t\t[] ),\n\t\t\t\t\t\tentityConfig.revisionKey || DEFAULT_ENTITY_KEY,\n\t\t\t\t\t] ),\n\t\t\t\t].join(),\n\t\t\t};\n\t\t}\n\n\t\tconst path = addQueryArgs(\n\t\t\tentityConfig.getRevisionsUrl( recordKey ),\n\t\t\tquery\n\t\t);\n\n\t\tlet records, response;\n\t\tconst meta = {};\n\t\tconst isPaginated =\n\t\t\tentityConfig.supportsPagination && query.per_page !== -1;\n\t\ttry {\n\t\t\tresponse = await apiFetch( { path, parse: ! isPaginated } );\n\t\t} catch ( error ) {\n\t\t\t// Do nothing if our request comes back with an API error.\n\t\t\treturn;\n\t\t}\n\n\t\tif ( response ) {\n\t\t\tif ( isPaginated ) {\n\t\t\t\trecords = Object.values( await response.json() );\n\t\t\t\tmeta.totalItems = parseInt(\n\t\t\t\t\tresponse.headers.get( 'X-WP-Total' )\n\t\t\t\t);\n\t\t\t} else {\n\t\t\t\trecords = Object.values( response );\n\t\t\t}\n\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 \"fulfilled\".\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\tregistry.batch( () => {\n\t\t\t\tdispatch.receiveRevisions(\n\t\t\t\t\tkind,\n\t\t\t\t\tname,\n\t\t\t\t\trecordKey,\n\t\t\t\t\trecords,\n\t\t\t\t\tquery,\n\t\t\t\t\tfalse,\n\t\t\t\t\tmeta\n\t\t\t\t);\n\n\t\t\t\t// When requesting all fields, the list of results can be used to\n\t\t\t\t// resolve the `getRevision` selector in addition to `getRevisions`.\n\t\t\t\tif ( ! query?._fields && ! query.context ) {\n\t\t\t\t\tconst key = entityConfig.key || DEFAULT_ENTITY_KEY;\n\t\t\t\t\tconst resolutionsArgs = records\n\t\t\t\t\t\t.filter( ( record ) => record[ key ] )\n\t\t\t\t\t\t.map( ( record ) => [\n\t\t\t\t\t\t\tkind,\n\t\t\t\t\t\t\tname,\n\t\t\t\t\t\t\trecordKey,\n\t\t\t\t\t\t\trecord[ key ],\n\t\t\t\t\t\t] );\n\n\t\t\t\t\tdispatch.finishResolutions(\n\t\t\t\t\t\t'getRevision',\n\t\t\t\t\t\tresolutionsArgs\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t} );\n\t\t}\n\t};\n\n// Invalidate cache when a new revision is created.\ngetRevisions.shouldInvalidate = ( action, kind, name, recordKey ) =>\n\taction.type === 'SAVE_ENTITY_RECORD_FINISH' &&\n\tname === action.name &&\n\tkind === action.kind &&\n\t! action.error &&\n\trecordKey === action.recordId;\n\n/**\n * Requests a specific Entity revision from the REST API.\n *\n * @param {string} kind Entity kind.\n * @param {string} name Entity name.\n * @param {number|string} recordKey The key of the entity record whose revisions you want to fetch.\n * @param {number|string} revisionKey The revision'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 getRevision =\n\t( kind, name, recordKey, revisionKey, query ) =>\n\tasync ( { dispatch, resolveSelect } ) => {\n\t\tconst configs = await resolveSelect.getEntitiesConfig( kind );\n\t\tconst entityConfig = configs.find(\n\t\t\t( config ) => config.name === name && config.kind === kind\n\t\t);\n\n\t\tif ( ! entityConfig ) {\n\t\t\treturn;\n\t\t}\n\n\t\tif ( query !== undefined && query._fields ) {\n\t\t\t// If requesting specific fields, items and query association to said\n\t\t\t// records are stored by ID reference. Thus, fields must always include\n\t\t\t// the ID.\n\t\t\tquery = {\n\t\t\t\t...query,\n\t\t\t\t_fields: [\n\t\t\t\t\t...new Set( [\n\t\t\t\t\t\t...( getNormalizedCommaSeparable( query._fields ) ||\n\t\t\t\t\t\t\t[] ),\n\t\t\t\t\t\tentityConfig.revisionKey || DEFAULT_ENTITY_KEY,\n\t\t\t\t\t] ),\n\t\t\t\t].join(),\n\t\t\t};\n\t\t}\n\t\tconst path = addQueryArgs(\n\t\t\tentityConfig.getRevisionsUrl( recordKey, revisionKey ),\n\t\t\tquery\n\t\t);\n\n\t\tlet record;\n\t\ttry {\n\t\t\trecord = await apiFetch( { path } );\n\t\t} catch ( error ) {\n\t\t\t// Do nothing if our request comes back with an API error.\n\t\t\treturn;\n\t\t}\n\n\t\tif ( record ) {\n\t\t\tdispatch.receiveRevisions( kind, name, recordKey, record, query );\n\t\t}\n\t};\n\n/**\n * Requests a specific post type options from the REST API.\n *\n * @param {string} postType Post type slug.\n */\nexport const getRegisteredPostMeta =\n\t( postType ) =>\n\tasync ( { dispatch, resolveSelect } ) => {\n\t\tlet options;\n\t\ttry {\n\t\t\tconst {\n\t\t\t\trest_namespace: restNamespace = 'wp/v2',\n\t\t\t\trest_base: restBase,\n\t\t\t} = ( await resolveSelect.getPostType( postType ) ) || {};\n\t\t\toptions = await apiFetch( {\n\t\t\t\tpath: `${ restNamespace }/${ restBase }/?context=edit`,\n\t\t\t\tmethod: 'OPTIONS',\n\t\t\t} );\n\t\t} catch ( error ) {\n\t\t\t// Do nothing if the request comes back with an API error.\n\t\t\treturn;\n\t\t}\n\n\t\tif ( options ) {\n\t\t\tdispatch.receiveRegisteredPostMeta(\n\t\t\t\tpostType,\n\t\t\t\toptions?.schema?.properties?.meta?.properties\n\t\t\t);\n\t\t}\n\t};\n\n/**\n * Requests entity configs for the given kind from the REST API.\n *\n * @param {string} kind Entity kind.\n */\nexport const getEntitiesConfig =\n\t( kind ) =>\n\tasync ( { dispatch } ) => {\n\t\tconst loader = additionalEntityConfigLoaders.find(\n\t\t\t( l ) => l.kind === kind\n\t\t);\n\n\t\tif ( ! loader ) {\n\t\t\treturn;\n\t\t}\n\n\t\ttry {\n\t\t\tconst configs = await loader.loadEntities();\n\t\t\tif ( ! configs.length ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tdispatch.addEntities( configs );\n\t\t} catch {\n\t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AAW,CAAEN,QAAS,CAAC,KAAM,CAAC,CAAC;IACzDmE,OAAO,GAAG,MAAM,IAAA/L,iBAAQ,EAAE;MACzBH,IAAI,EAAE,GAAIoI,aAAa,IAAMF,QAAQ,gBAAiB;MACtDR,MAAM,EAAE;IACT,CAAE,CAAC;EACJ,CAAC,CAAC,OAAQV,KAAK,EAAG;IACjB;IACA;EACD;EAEA,IAAKkF,OAAO,EAAG;IACdnM,QAAQ,CAACoM,yBAAyB,CACjCpE,QAAQ,EACRmE,OAAO,EAAEE,MAAM,EAAEC,UAAU,EAAE7J,IAAI,EAAE6J,UACpC,CAAC;EACF;AACD,CAAC;;AAEF;AACA;AACA;AACA;AACA;AAJAhM,OAAA,CAAA4L,qBAAA,GAAAA,qBAAA;AAKO,MAAMhL,iBAAiB,GAC3BP,IAAI,IACN,OAAQ;EAAEX;AAAS,CAAC,KAAM;EACzB,MAAMuM,MAAM,GAAGC,uCAA6B,CAACpL,IAAI,CAC9CqL,CAAC,IAAMA,CAAC,CAAC9L,IAAI,KAAKA,IACrB,CAAC;EAED,IAAK,CAAE4L,MAAM,EAAG;IACf;EACD;EAEA,IAAI;IACH,MAAMtL,OAAO,GAAG,MAAMsL,MAAM,CAACG,YAAY,CAAC,CAAC;IAC3C,IAAK,CAAEzL,OAAO,CAACyE,MAAM,EAAG;MACvB;IACD;IAEA1F,QAAQ,CAAC2M,WAAW,CAAE1L,OAAQ,CAAC;EAChC,CAAC,CAAC,MAAM;IACP;EAAA;AAEF,CAAC;AAACX,OAAA,CAAAY,iBAAA,GAAAA,iBAAA","ignoreList":[]}
@@ -235,7 +235,7 @@ function getEntityConfig(state, kind, name) {
235
235
  * @param state State tree
236
236
  * @param kind Entity kind.
237
237
  * @param name Entity name.
238
- * @param key Record's key
238
+ * @param key Optional record's key. If requesting a global record (e.g. site settings), the key can be omitted. If requesting a specific item, the key must always be included.
239
239
  * @param query Optional query. If requesting specific
240
240
  * fields, fields must always include the ID. For valid query parameters see the [Reference](https://developer.wordpress.org/rest-api/reference/) in the REST API Handbook and select the entity kind. Then see the arguments available "Retrieve a [Entity kind]".
241
241
  *