@wordpress/core-data 4.2.0 → 4.4.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.
- package/CHANGELOG.md +8 -0
- package/README.md +68 -11
- package/build/actions.js +61 -41
- package/build/actions.js.map +1 -1
- package/build/batch/default-processor.js +1 -1
- package/build/batch/default-processor.js.map +1 -1
- package/build/entities.js +36 -23
- package/build/entities.js.map +1 -1
- package/build/entity-provider.js +46 -44
- package/build/entity-provider.js.map +1 -1
- package/build/entity-types/{base-entity-types.js → base-entity-records.js} +9 -9
- package/build/entity-types/base-entity-records.js.map +1 -0
- package/build/fetch/__experimental-fetch-link-suggestions.js +48 -11
- package/build/fetch/__experimental-fetch-link-suggestions.js.map +1 -1
- package/build/fetch/__experimental-fetch-url-data.js +1 -1
- package/build/fetch/__experimental-fetch-url-data.js.map +1 -1
- package/build/hooks/use-entity-record.js +15 -5
- package/build/hooks/use-entity-record.js.map +1 -1
- package/build/hooks/use-entity-records.js +14 -2
- package/build/hooks/use-entity-records.js.map +1 -1
- package/build/hooks/use-query-select.js.map +1 -1
- package/build/index.js +9 -21
- package/build/index.js.map +1 -1
- package/build/queried-data/actions.js +4 -4
- package/build/queried-data/actions.js.map +1 -1
- package/build/queried-data/get-query-parts.js +7 -3
- package/build/queried-data/get-query-parts.js.map +1 -1
- package/build/queried-data/reducer.js +8 -6
- package/build/queried-data/reducer.js.map +1 -1
- package/build/reducer.js +77 -25
- package/build/reducer.js.map +1 -1
- package/build/resolvers.js +48 -24
- package/build/resolvers.js.map +1 -1
- package/build/selectors.js +122 -55
- package/build/selectors.js.map +1 -1
- package/build/types.js +6 -0
- package/build/types.js.map +1 -0
- package/build/utils/conservative-map-item.js +1 -1
- package/build/utils/conservative-map-item.js.map +1 -1
- package/build/utils/if-matching-action.js +4 -2
- package/build/utils/if-matching-action.js.map +1 -1
- package/build/utils/is-raw-attribute.js +1 -1
- package/build/utils/is-raw-attribute.js.map +1 -1
- package/build/utils/on-sub-key.js +3 -1
- package/build/utils/on-sub-key.js.map +1 -1
- package/build/utils/replace-action.js +4 -2
- package/build/utils/replace-action.js.map +1 -1
- package/build-module/actions.js +62 -42
- package/build-module/actions.js.map +1 -1
- package/build-module/batch/default-processor.js +1 -1
- package/build-module/batch/default-processor.js.map +1 -1
- package/build-module/entities.js +32 -19
- package/build-module/entities.js.map +1 -1
- package/build-module/entity-provider.js +47 -45
- package/build-module/entity-provider.js.map +1 -1
- package/build-module/entity-types/{base-entity-types.js → base-entity-records.js} +7 -7
- package/build-module/entity-types/base-entity-records.js.map +1 -0
- package/build-module/fetch/__experimental-fetch-link-suggestions.js +48 -11
- package/build-module/fetch/__experimental-fetch-link-suggestions.js.map +1 -1
- package/build-module/fetch/__experimental-fetch-url-data.js +1 -1
- package/build-module/fetch/__experimental-fetch-url-data.js.map +1 -1
- package/build-module/hooks/use-entity-record.js +15 -5
- package/build-module/hooks/use-entity-record.js.map +1 -1
- package/build-module/hooks/use-entity-records.js +14 -2
- package/build-module/hooks/use-entity-records.js.map +1 -1
- package/build-module/hooks/use-query-select.js.map +1 -1
- package/build-module/index.js +10 -22
- package/build-module/index.js.map +1 -1
- package/build-module/queried-data/actions.js +4 -4
- package/build-module/queried-data/actions.js.map +1 -1
- package/build-module/queried-data/get-query-parts.js +7 -3
- package/build-module/queried-data/get-query-parts.js.map +1 -1
- package/build-module/queried-data/reducer.js +8 -6
- package/build-module/queried-data/reducer.js.map +1 -1
- package/build-module/reducer.js +75 -26
- package/build-module/reducer.js.map +1 -1
- package/build-module/resolvers.js +42 -24
- package/build-module/resolvers.js.map +1 -1
- package/build-module/selectors.js +114 -55
- package/build-module/selectors.js.map +1 -1
- package/build-module/types.js +2 -0
- package/build-module/types.js.map +1 -0
- package/build-module/utils/conservative-map-item.js +1 -1
- package/build-module/utils/conservative-map-item.js.map +1 -1
- package/build-module/utils/if-matching-action.js +4 -2
- package/build-module/utils/if-matching-action.js.map +1 -1
- package/build-module/utils/is-raw-attribute.js +1 -1
- package/build-module/utils/is-raw-attribute.js.map +1 -1
- package/build-module/utils/on-sub-key.js +3 -1
- package/build-module/utils/on-sub-key.js.map +1 -1
- package/build-module/utils/replace-action.js +4 -2
- package/build-module/utils/replace-action.js.map +1 -1
- package/package.json +11 -11
- package/src/actions.js +62 -42
- package/src/batch/default-processor.js +1 -0
- package/src/{entities.js → entities.ts} +50 -21
- package/src/entity-provider.js +50 -44
- package/src/entity-types/attachment.ts +5 -5
- package/src/entity-types/{base-entity-types.ts → base-entity-records.ts} +5 -5
- package/src/entity-types/comment.ts +5 -5
- package/src/entity-types/helpers.ts +1 -1
- package/src/entity-types/index.ts +4 -4
- package/src/entity-types/menu-location.ts +5 -5
- package/src/entity-types/nav-menu-item.ts +10 -5
- package/src/entity-types/nav-menu.ts +5 -5
- package/src/entity-types/navigation-area.ts +5 -5
- package/src/entity-types/page.ts +5 -5
- package/src/entity-types/plugin.ts +10 -5
- package/src/entity-types/post.ts +5 -5
- package/src/entity-types/settings.ts +10 -5
- package/src/entity-types/sidebar.ts +6 -7
- package/src/entity-types/taxonomy.ts +5 -5
- package/src/entity-types/theme.ts +5 -5
- package/src/entity-types/type.ts +5 -5
- package/src/entity-types/user.ts +10 -5
- package/src/entity-types/widget-type.ts +5 -5
- package/src/entity-types/widget.ts +5 -5
- package/src/entity-types/wp-template-part.ts +5 -5
- package/src/entity-types/wp-template.ts +5 -5
- package/src/fetch/__experimental-fetch-link-suggestions.js +56 -20
- package/src/fetch/__experimental-fetch-url-data.js +1 -0
- package/src/fetch/test/__experimental-fetch-link-suggestions.js +39 -1
- package/src/hooks/use-entity-record.ts +19 -8
- package/src/hooks/use-entity-records.ts +23 -6
- package/src/hooks/use-query-select.ts +12 -7
- package/src/index.js +10 -15
- package/src/locks/test/selectors.js +4 -4
- package/src/queried-data/actions.js +4 -4
- package/src/queried-data/get-query-parts.js +5 -5
- package/src/queried-data/reducer.js +6 -6
- package/src/reducer.js +67 -24
- package/src/resolvers.js +39 -30
- package/src/{selectors.js → selectors.ts} +118 -57
- package/src/test/actions.js +138 -33
- package/src/test/entities.js +11 -11
- package/src/test/reducer.js +4 -4
- package/src/test/resolvers.js +5 -5
- package/src/test/selectors.js +22 -22
- package/src/types.ts +3 -0
- package/src/utils/conservative-map-item.js +1 -1
- package/src/utils/if-matching-action.js +4 -2
- package/src/utils/is-raw-attribute.js +1 -1
- package/src/utils/on-sub-key.js +3 -1
- package/src/utils/replace-action.js +4 -2
- package/src/utils/test/is-raw-attribute.js +4 -4
- package/build/entity-types/base-entity-types.js.map +0 -1
- package/build-module/entity-types/base-entity-types.js.map +0 -1
package/build/resolvers.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/core-data/src/resolvers.js"],"names":["getAuthors","query","dispatch","path","users","receiveUserQuery","getCurrentUser","currentUser","receiveCurrentUser","getEntityRecord","kind","name","key","select","entities","entity","__experimentalNoFetch","lock","__unstableAcquireStoreLock","STORE_NAME","exclusive","undefined","_fields","DEFAULT_ENTITY_KEY","join","baseURL","baseURLParams","include","hasRecords","hasEntityRecords","record","receiveEntityRecords","error","__unstableReleaseStoreLock","getRawEntityRecord","getEditedEntityRecord","getEntityRecords","records","Object","values","map","split","forEach","field","hasOwnProperty","context","resolutionsArgs","filter","type","selectorName","args","shouldInvalidate","action","invalidateCache","getCurrentTheme","resolveSelect","activeThemes","status","receiveCurrentTheme","getThemeSupports","getEmbedPreview","url","embedProxyResponse","receiveEmbedPreview","canUser","resource","id","methods","create","read","update","delete","method","Error","response","parse","allowHeader","headers","get","isAllowed","receiveUserPermission","canUserEditEntityRecord","recordId","__unstable_rest_base","getAutosaves","postType","postId","rest_base","restBase","getPostType","autosaves","length","receiveAutosaves","getAutosave","__experimentalGetTemplateForLink","link","template","window","fetch","then","res","json","data","e","__experimentalGetCurrentGlobalStylesId","globalStylesURL","globalStylesObject","__experimentalReceiveCurrentGlobalStylesId","__experimentalGetCurrentThemeBaseGlobalStyles","currentTheme","themeGlobalStyles","stylesheet","__experimentalReceiveThemeBaseGlobalStyles","__experimentalGetCurrentThemeGlobalStylesVariations","variations","__experimentalReceiveThemeGlobalStyleVariations"],"mappings":";;;;;;;;;AAGA;;AAKA;;AACA;;AAKA;;AACA;;AACA;;AAhBA;AACA;AACA;;AAGA;AACA;AACA;;AAIA;AACA;AACA;;AAKA;AACA;AACA;AACA;AACA;AACA;AACO,MAAMA,UAAU,GAAKC,KAAF,IAAa,cAA0B;AAAA,MAAlB;AAAEC,IAAAA;AAAF,GAAkB;AAChE,QAAMC,IAAI,GAAG,uBACZ,wCADY,EAEZF,KAFY,CAAb;AAIA,QAAMG,KAAK,GAAG,MAAM,uBAAU;AAAED,IAAAA;AAAF,GAAV,CAApB;AACAD,EAAAA,QAAQ,CAACG,gBAAT,CAA2BF,IAA3B,EAAiCC,KAAjC;AACA,CAPM;AASP;AACA;AACA;;;;;AACO,MAAME,cAAc,GAAG,MAAM,eAA0B;AAAA,MAAlB;AAAEJ,IAAAA;AAAF,GAAkB;AAC7D,QAAMK,WAAW,GAAG,MAAM,uBAAU;AAAEJ,IAAAA,IAAI,EAAE;AAAR,GAAV,CAA1B;AACAD,EAAAA,QAAQ,CAACM,kBAAT,CAA6BD,WAA7B;AACA,CAHM;AAKP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;AACO,MAAME,eAAe,GAAG,UAAEC,IAAF,EAAQC,IAAR;AAAA,MAAcC,GAAd,uEAAoB,EAApB;AAAA,MAAwBX,KAAxB;AAAA,SAAmC,eAG3D;AAAA,QAHmE;AACzEY,MAAAA,MADyE;AAEzEX,MAAAA;AAFyE,KAGnE;AACN,UAAMY,QAAQ,GAAG,MAAMZ,QAAQ,CAAE,+BAAiBQ,IAAjB,CAAF,CAA/B;AACA,UAAMK,MAAM,GAAG,kBAAMD,QAAN,EAAgB;AAAEJ,MAAAA,IAAF;AAAQC,MAAAA;AAAR,KAAhB,CAAf;;AACA,QAAK,CAAEI,MAAF,IAAYA,MAAZ,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AT,CACCH,YAAY,CAACE,UADd,EAECD,iBAFD;AAIA,CAZM;;;;AAcA,MAAMG,mDAAmD,GAAG,MAAM,gBAGlE;AAAA,MAH0E;AAChF1D,IAAAA,aADgF;AAEhFrD,IAAAA;AAFgF,GAG1E;AACN,QAAM2G,YAAY,GAAG,MAAMtD,aAAa,CAACD,eAAd,EAA3B;AACA,QAAM4D,UAAU,GAAG,MAAM,uBAAU;AAClC/G,IAAAA,IAAI,EAAG,+BAA+B0G,YAAY,CAACE,UAAY;AAD7B,GAAV,CAAzB;;AAGA7G,EAAAA,QAAQ,CAACiH,+CAAT,CACCN,YAAY,CAACE,UADd,EAECG,UAFD;AAIA,CAZM","sourcesContent":["/**\n * External dependencies\n */\nimport { find, includes, get, compact, uniq } from 'lodash';\n\n/**\n * WordPress dependencies\n */\nimport { addQueryArgs } from '@wordpress/url';\nimport apiFetch from '@wordpress/api-fetch';\n\n/**\n * Internal dependencies\n */\nimport { STORE_NAME } from './name';\nimport { getKindEntities, DEFAULT_ENTITY_KEY } from './entities';\nimport { forwardResolver, getNormalizedCommaSeparable } from './utils';\n\n/**\n * Requests authors from the REST API.\n *\n * @param {Object|undefined} query Optional object of query parameters to\n * include with request.\n */\nexport const getAuthors = ( query ) => async ( { dispatch } ) => {\n\tconst path = addQueryArgs(\n\t\t'/wp/v2/users/?who=authors&per_page=100',\n\t\tquery\n\t);\n\tconst users = await apiFetch( { path } );\n\tdispatch.receiveUserQuery( path, users );\n};\n\n/**\n * Requests the current user from the REST API.\n */\nexport const getCurrentUser = () => async ( { dispatch } ) => {\n\tconst currentUser = await apiFetch( { path: '/wp/v2/users/me' } );\n\tdispatch.receiveCurrentUser( currentUser );\n};\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.\n */\nexport const getEntityRecord = ( kind, name, key = '', query ) => async ( {\n\tselect,\n\tdispatch,\n} ) => {\n\tconst entities = await dispatch( getKindEntities( kind ) );\n\tconst entity = find( entities, { kind, name } );\n\tif ( ! entity || entity?.__experimentalNoFetch ) {\n\t\treturn;\n\t}\n\n\tconst lock = await dispatch.__unstableAcquireStoreLock(\n\t\tSTORE_NAME,\n\t\t[ 'entities', 'data', kind, name, key ],\n\t\t{ exclusive: false }\n\t);\n\n\ttry {\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: uniq( [\n\t\t\t\t\t...( getNormalizedCommaSeparable( query._fields ) || [] ),\n\t\t\t\t\tentity.key || DEFAULT_ENTITY_KEY,\n\t\t\t\t] ).join(),\n\t\t\t};\n\t\t}\n\n\t\t// Disable reason: While true that an early return could leave `path`\n\t\t// unused, it's important that path is derived using the query prior to\n\t\t// additional query modifications in the condition below, since those\n\t\t// modifications are relevant to how the data is tracked in state, and not\n\t\t// for how the request is made to the REST API.\n\n\t\t// eslint-disable-next-line @wordpress/no-unused-vars-before-return\n\t\tconst path = addQueryArgs( entity.baseURL + ( key ? '/' + key : '' ), {\n\t\t\t...entity.baseURLParams,\n\t\t\t...query,\n\t\t} );\n\n\t\tif ( query !== undefined ) {\n\t\t\tquery = { ...query, include: [ key ] };\n\n\t\t\t// The resolution cache won't consider query as reusable based on the\n\t\t\t// fields, so it's tested here, prior to initiating the REST request,\n\t\t\t// and without causing `getEntityRecords` resolution to occur.\n\t\t\tconst hasRecords = select.hasEntityRecords( kind, name, query );\n\t\t\tif ( hasRecords ) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t}\n\n\t\tconst record = await apiFetch( { path } );\n\t\tdispatch.receiveEntityRecords( kind, name, record, query );\n\t} catch ( error ) {\n\t\t// We need a way to handle and access REST API errors in state\n\t\t// Until then, catching the error ensures the resolver is marked as resolved.\n\t\t// See similar implementation in `getEntityRecords()`.\n\t} finally {\n\t\tdispatch.__unstableReleaseStoreLock( lock );\n\t}\n};\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.\n */\nexport const getEntityRecords = ( kind, name, query = {} ) => async ( {\n\tdispatch,\n} ) => {\n\tconst entities = await dispatch( getKindEntities( kind ) );\n\tconst entity = find( entities, { kind, name } );\n\tif ( ! entity || entity?.__experimentalNoFetch ) {\n\t\treturn;\n\t}\n\n\tconst lock = await dispatch.__unstableAcquireStoreLock(\n\t\tSTORE_NAME,\n\t\t[ 'entities', 'data', kind, name ],\n\t\t{ exclusive: false }\n\t);\n\n\ttry {\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: uniq( [\n\t\t\t\t\t...( getNormalizedCommaSeparable( query._fields ) || [] ),\n\t\t\t\t\tentity.key || DEFAULT_ENTITY_KEY,\n\t\t\t\t] ).join(),\n\t\t\t};\n\t\t}\n\n\t\tconst path = addQueryArgs( entity.baseURL, {\n\t\t\t...entity.baseURLParams,\n\t\t\t...query,\n\t\t} );\n\n\t\tlet records = Object.values( await apiFetch( { path } ) );\n\t\t// If we request fields but the result doesn't contain the fields,\n\t\t// explicitely set these fields as \"undefined\"\n\t\t// that way we consider the query \"fullfilled\".\n\t\tif ( query._fields ) {\n\t\t\trecords = records.map( ( record ) => {\n\t\t\t\tquery._fields.split( ',' ).forEach( ( field ) => {\n\t\t\t\t\tif ( ! record.hasOwnProperty( field ) ) {\n\t\t\t\t\t\trecord[ field ] = undefined;\n\t\t\t\t\t}\n\t\t\t\t} );\n\n\t\t\t\treturn record;\n\t\t\t} );\n\t\t}\n\n\t\tdispatch.receiveEntityRecords( kind, name, records, query );\n\n\t\t// When requesting all fields, the list of results can be used to\n\t\t// resolve the `getEntityRecord` selector in addition to `getEntityRecords`.\n\t\t// See https://github.com/WordPress/gutenberg/pull/26575\n\t\tif ( ! query?._fields && ! query.context ) {\n\t\t\tconst key = entity.key || DEFAULT_ENTITY_KEY;\n\t\t\tconst resolutionsArgs = records\n\t\t\t\t.filter( ( record ) => record[ key ] )\n\t\t\t\t.map( ( record ) => [ kind, name, record[ key ] ] );\n\n\t\t\tdispatch( {\n\t\t\t\ttype: 'START_RESOLUTIONS',\n\t\t\t\tselectorName: 'getEntityRecord',\n\t\t\t\targs: resolutionsArgs,\n\t\t\t} );\n\t\t\tdispatch( {\n\t\t\t\ttype: 'FINISH_RESOLUTIONS',\n\t\t\t\tselectorName: 'getEntityRecord',\n\t\t\t\targs: resolutionsArgs,\n\t\t\t} );\n\t\t}\n\t} catch ( error ) {\n\t\t// We need a way to handle and access REST API errors in state\n\t\t// Until then, catching the error ensures the resolver is marked as resolved.\n\t\t// See similar implementation in `getEntityRecord()`.\n\t} finally {\n\t\tdispatch.__unstableReleaseStoreLock( lock );\n\t}\n};\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 = () => async ( { dispatch, resolveSelect } ) => {\n\tconst activeThemes = await resolveSelect.getEntityRecords(\n\t\t'root',\n\t\t'theme',\n\t\t{ status: 'active' }\n\t);\n\n\tdispatch.receiveCurrentTheme( activeThemes[ 0 ] );\n};\n\n/**\n * Requests theme supports data from the index.\n */\nexport const getThemeSupports = forwardResolver( 'getCurrentTheme' );\n\n/**\n * Requests a preview from the from the Embed API.\n *\n * @param {string} url URL to get the preview for.\n */\nexport const getEmbedPreview = ( url ) => async ( { dispatch } ) => {\n\ttry {\n\t\tconst embedProxyResponse = await apiFetch( {\n\t\t\tpath: addQueryArgs( '/oembed/1.0/proxy', { url } ),\n\t\t} );\n\t\tdispatch.receiveEmbedPreview( url, embedProxyResponse );\n\t} catch ( error ) {\n\t\t// Embed API 404s if the URL cannot be embedded, so we have to catch the error from the apiRequest here.\n\t\tdispatch.receiveEmbedPreview( url, false );\n\t}\n};\n\n/**\n * Checks whether the current user can perform the given action on the given\n * REST resource.\n *\n * @param {string} action Action to check. One of: 'create', 'read', 'update',\n * 'delete'.\n * @param {string} resource REST resource to check, e.g. 'media' or 'posts'.\n * @param {?string} id ID of the rest resource to check.\n */\nexport const canUser = ( action, resource, id ) => async ( { dispatch } ) => {\n\tconst methods = {\n\t\tcreate: 'POST',\n\t\tread: 'GET',\n\t\tupdate: 'PUT',\n\t\tdelete: 'DELETE',\n\t};\n\n\tconst method = methods[ action ];\n\tif ( ! method ) {\n\t\tthrow new Error( `'${ action }' is not a valid action.` );\n\t}\n\n\tconst path = id ? `/wp/v2/${ resource }/${ id }` : `/wp/v2/${ resource }`;\n\n\tlet response;\n\ttry {\n\t\tresponse = await apiFetch( {\n\t\t\tpath,\n\t\t\tmethod: 'OPTIONS',\n\t\t\tparse: false,\n\t\t} );\n\t} catch ( error ) {\n\t\t// Do nothing if our OPTIONS request comes back with an API error (4xx or\n\t\t// 5xx). The previously determined isAllowed value will remain in the store.\n\t\treturn;\n\t}\n\n\t// Optional chaining operator is used here because the API requests don't\n\t// return the expected result in the native version. Instead, API requests\n\t// only return the result, without including response properties like the headers.\n\tconst allowHeader = response.headers?.get( 'allow' );\n\tconst key = compact( [ action, resource, id ] ).join( '/' );\n\tconst isAllowed = includes( allowHeader, method );\n\tdispatch.receiveUserPermission( key, isAllowed );\n};\n\n/**\n * Checks whether the current user can perform the given action on the given\n * REST resource.\n *\n * @param {string} kind Entity kind.\n * @param {string} name Entity name.\n * @param {string} recordId Record's id.\n */\nexport const canUserEditEntityRecord = ( kind, name, recordId ) => async ( {\n\tdispatch,\n} ) => {\n\tconst entities = await dispatch( getKindEntities( kind ) );\n\tconst entity = find( entities, { kind, name } );\n\tif ( ! entity ) {\n\t\treturn;\n\t}\n\n\tconst resource = entity.__unstable_rest_base;\n\tawait dispatch( canUser( 'update', resource, recordId ) );\n};\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 = ( postType, postId ) => async ( {\n\tdispatch,\n\tresolveSelect,\n} ) => {\n\tconst { rest_base: restBase } = await resolveSelect.getPostType( postType );\n\tconst autosaves = await apiFetch( {\n\t\tpath: `/wp/v2/${ restBase }/${ postId }/autosaves?context=edit`,\n\t} );\n\n\tif ( autosaves && autosaves.length ) {\n\t\tdispatch.receiveAutosaves( postId, autosaves );\n\t}\n};\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 = ( postType, postId ) => async ( {\n\tresolveSelect,\n} ) => {\n\tawait resolveSelect.getAutosaves( postType, postId );\n};\n\n/**\n * Retrieve the frontend template used for a given link.\n *\n * @param {string} link Link.\n */\nexport const __experimentalGetTemplateForLink = ( link ) => async ( {\n\tdispatch,\n\tresolveSelect,\n} ) => {\n\t// Ideally this should be using an apiFetch call\n\t// We could potentially do so by adding a \"filter\" to the `wp_template` end point.\n\t// Also it seems the returned object is not a regular REST API post type.\n\tlet template;\n\ttry {\n\t\ttemplate = await window\n\t\t\t.fetch( addQueryArgs( link, { '_wp-find-template': true } ) )\n\t\t\t.then( ( res ) => res.json() )\n\t\t\t.then( ( { data } ) => data );\n\t} catch ( e ) {\n\t\t// For non-FSE themes, it is possible that this request returns an error.\n\t}\n\n\tif ( ! template ) {\n\t\treturn;\n\t}\n\n\tconst record = await resolveSelect.getEntityRecord(\n\t\t'postType',\n\t\t'wp_template',\n\t\ttemplate.id\n\t);\n\n\tif ( record ) {\n\t\tdispatch.receiveEntityRecords( 'postType', 'wp_template', [ record ], {\n\t\t\t'find-template': link,\n\t\t} );\n\t}\n};\n\n__experimentalGetTemplateForLink.shouldInvalidate = ( action ) => {\n\treturn (\n\t\t( action.type === 'RECEIVE_ITEMS' || action.type === 'REMOVE_ITEMS' ) &&\n\t\taction.invalidateCache &&\n\t\taction.kind === 'postType' &&\n\t\taction.name === 'wp_template'\n\t);\n};\n\nexport const __experimentalGetCurrentGlobalStylesId = () => async ( {\n\tdispatch,\n\tresolveSelect,\n} ) => {\n\tconst activeThemes = await resolveSelect.getEntityRecords(\n\t\t'root',\n\t\t'theme',\n\t\t{ status: 'active' }\n\t);\n\tconst globalStylesURL = get( activeThemes, [\n\t\t0,\n\t\t'_links',\n\t\t'wp:user-global-styles',\n\t\t0,\n\t\t'href',\n\t] );\n\tif ( globalStylesURL ) {\n\t\tconst globalStylesObject = await apiFetch( {\n\t\t\turl: globalStylesURL,\n\t\t} );\n\t\tdispatch.__experimentalReceiveCurrentGlobalStylesId(\n\t\t\tglobalStylesObject.id\n\t\t);\n\t}\n};\n\nexport const __experimentalGetCurrentThemeBaseGlobalStyles = () => async ( {\n\tresolveSelect,\n\tdispatch,\n} ) => {\n\tconst currentTheme = await resolveSelect.getCurrentTheme();\n\tconst themeGlobalStyles = await apiFetch( {\n\t\tpath: `/wp/v2/global-styles/themes/${ currentTheme.stylesheet }`,\n\t} );\n\tdispatch.__experimentalReceiveThemeBaseGlobalStyles(\n\t\tcurrentTheme.stylesheet,\n\t\tthemeGlobalStyles\n\t);\n};\n\nexport const __experimentalGetCurrentThemeGlobalStylesVariations = () => async ( {\n\tresolveSelect,\n\tdispatch,\n} ) => {\n\tconst currentTheme = await resolveSelect.getCurrentTheme();\n\tconst variations = await apiFetch( {\n\t\tpath: `/wp/v2/global-styles/themes/${ currentTheme.stylesheet }/variations`,\n\t} );\n\tdispatch.__experimentalReceiveThemeGlobalStyleVariations(\n\t\tcurrentTheme.stylesheet,\n\t\tvariations\n\t);\n};\n"]}
|
|
1
|
+
{"version":3,"sources":["@wordpress/core-data/src/resolvers.js"],"names":["getAuthors","query","dispatch","path","users","receiveUserQuery","getCurrentUser","currentUser","receiveCurrentUser","getEntityRecord","kind","name","key","select","configs","entityConfig","__experimentalNoFetch","lock","__unstableAcquireStoreLock","STORE_NAME","exclusive","undefined","_fields","DEFAULT_ENTITY_KEY","join","baseURL","baseURLParams","include","hasRecords","hasEntityRecords","record","receiveEntityRecords","__unstableReleaseStoreLock","getRawEntityRecord","getEditedEntityRecord","getEntityRecords","records","Object","values","map","split","forEach","field","hasOwnProperty","context","resolutionsArgs","filter","type","selectorName","args","shouldInvalidate","action","invalidateCache","getCurrentTheme","resolveSelect","activeThemes","status","receiveCurrentTheme","getThemeSupports","getEmbedPreview","url","embedProxyResponse","receiveEmbedPreview","error","canUser","resource","id","methods","create","read","update","delete","method","Error","response","parse","allowHeader","headers","get","isAllowed","receiveUserPermission","canUserEditEntityRecord","recordId","__unstable_rest_base","getAutosaves","postType","postId","rest_base","restBase","getPostType","autosaves","length","receiveAutosaves","getAutosave","__experimentalGetTemplateForLink","link","template","window","fetch","then","res","json","data","e","__experimentalGetCurrentGlobalStylesId","globalStylesURL","globalStylesObject","__experimentalReceiveCurrentGlobalStylesId","__experimentalGetCurrentThemeBaseGlobalStyles","currentTheme","themeGlobalStyles","stylesheet","__experimentalReceiveThemeBaseGlobalStyles","__experimentalGetCurrentThemeGlobalStylesVariations","variations","__experimentalReceiveThemeGlobalStyleVariations","getBlockPatterns","patterns","getBlockPatternCategories","categories"],"mappings":";;;;;;;;;AAGA;;AAKA;;AACA;;AAKA;;AACA;;AACA;;AAhBA;AACA;AACA;;AAGA;AACA;AACA;;AAIA;AACA;AACA;;AAKA;AACA;AACA;AACA;AACA;AACA;AACO,MAAMA,UAAU,GAAK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,UADd,EAECG,UAFD;AAIA,CAZM;;;;AAcA,MAAME,gBAAgB,GAAG,MAAM,gBAA0B;AAAA,MAAlB;AAAElH,IAAAA;AAAF,GAAkB;AAC/D,QAAMmH,QAAQ,GAAG,MAAM,uBAAU;AAChClH,IAAAA,IAAI,EAAE;AAD0B,GAAV,CAAvB;AAGAD,EAAAA,QAAQ,CAAE;AAAE6C,IAAAA,IAAI,EAAE,wBAAR;AAAkCsE,IAAAA;AAAlC,GAAF,CAAR;AACA,CALM;;;;AAOA,MAAMC,yBAAyB,GAAG,MAAM,gBAA0B;AAAA,MAAlB;AAAEpH,IAAAA;AAAF,GAAkB;AACxE,QAAMqH,UAAU,GAAG,MAAM,uBAAU;AAClCpH,IAAAA,IAAI,EAAE;AAD4B,GAAV,CAAzB;AAGAD,EAAAA,QAAQ,CAAE;AAAE6C,IAAAA,IAAI,EAAE,kCAAR;AAA4CwE,IAAAA;AAA5C,GAAF,CAAR;AACA,CALM","sourcesContent":["/**\n * External dependencies\n */\nimport { find, includes, get, compact, uniq } from 'lodash';\n\n/**\n * WordPress dependencies\n */\nimport { addQueryArgs } from '@wordpress/url';\nimport apiFetch from '@wordpress/api-fetch';\n\n/**\n * Internal dependencies\n */\nimport { STORE_NAME } from './name';\nimport { getOrLoadEntitiesConfig, DEFAULT_ENTITY_KEY } from './entities';\nimport { forwardResolver, getNormalizedCommaSeparable } from './utils';\n\n/**\n * Requests authors from the REST API.\n *\n * @param {Object|undefined} query Optional object of query parameters to\n * include with request.\n */\nexport const getAuthors = ( query ) => async ( { dispatch } ) => {\n\tconst path = addQueryArgs(\n\t\t'/wp/v2/users/?who=authors&per_page=100',\n\t\tquery\n\t);\n\tconst users = await apiFetch( { path } );\n\tdispatch.receiveUserQuery( path, users );\n};\n\n/**\n * Requests the current user from the REST API.\n */\nexport const getCurrentUser = () => async ( { dispatch } ) => {\n\tconst currentUser = await apiFetch( { path: '/wp/v2/users/me' } );\n\tdispatch.receiveCurrentUser( currentUser );\n};\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.\n */\nexport const getEntityRecord = ( kind, name, key = '', query ) => async ( {\n\tselect,\n\tdispatch,\n} ) => {\n\tconst configs = await dispatch( getOrLoadEntitiesConfig( kind ) );\n\tconst entityConfig = find( configs, { kind, name } );\n\tif ( ! entityConfig || entityConfig?.__experimentalNoFetch ) {\n\t\treturn;\n\t}\n\n\tconst lock = await dispatch.__unstableAcquireStoreLock(\n\t\tSTORE_NAME,\n\t\t[ 'entities', 'records', kind, name, key ],\n\t\t{ exclusive: false }\n\t);\n\n\ttry {\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: uniq( [\n\t\t\t\t\t...( getNormalizedCommaSeparable( query._fields ) || [] ),\n\t\t\t\t\tentityConfig.key || DEFAULT_ENTITY_KEY,\n\t\t\t\t] ).join(),\n\t\t\t};\n\t\t}\n\n\t\t// Disable reason: While true that an early return could leave `path`\n\t\t// unused, it's important that path is derived using the query prior to\n\t\t// additional query modifications in the condition below, since those\n\t\t// modifications are relevant to how the data is tracked in state, and not\n\t\t// for how the request is made to the REST API.\n\n\t\t// eslint-disable-next-line @wordpress/no-unused-vars-before-return\n\t\tconst path = addQueryArgs(\n\t\t\tentityConfig.baseURL + ( key ? '/' + key : '' ),\n\t\t\t{\n\t\t\t\t...entityConfig.baseURLParams,\n\t\t\t\t...query,\n\t\t\t}\n\t\t);\n\n\t\tif ( query !== undefined ) {\n\t\t\tquery = { ...query, include: [ key ] };\n\n\t\t\t// The resolution cache won't consider query as reusable based on the\n\t\t\t// fields, so it's tested here, prior to initiating the REST request,\n\t\t\t// and without causing `getEntityRecords` resolution to occur.\n\t\t\tconst hasRecords = select.hasEntityRecords( kind, name, query );\n\t\t\tif ( hasRecords ) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t}\n\n\t\tconst record = await apiFetch( { path } );\n\t\tdispatch.receiveEntityRecords( kind, name, record, query );\n\t} finally {\n\t\tdispatch.__unstableReleaseStoreLock( lock );\n\t}\n};\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.\n */\nexport const getEntityRecords = ( kind, name, query = {} ) => async ( {\n\tdispatch,\n} ) => {\n\tconst configs = await dispatch( getOrLoadEntitiesConfig( kind ) );\n\tconst entityConfig = find( configs, { kind, name } );\n\tif ( ! entityConfig || entityConfig?.__experimentalNoFetch ) {\n\t\treturn;\n\t}\n\n\tconst lock = await dispatch.__unstableAcquireStoreLock(\n\t\tSTORE_NAME,\n\t\t[ 'entities', 'records', kind, name ],\n\t\t{ exclusive: false }\n\t);\n\n\ttry {\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: uniq( [\n\t\t\t\t\t...( getNormalizedCommaSeparable( query._fields ) || [] ),\n\t\t\t\t\tentityConfig.key || DEFAULT_ENTITY_KEY,\n\t\t\t\t] ).join(),\n\t\t\t};\n\t\t}\n\n\t\tconst path = addQueryArgs( entityConfig.baseURL, {\n\t\t\t...entityConfig.baseURLParams,\n\t\t\t...query,\n\t\t} );\n\n\t\tlet records = Object.values( await apiFetch( { path } ) );\n\t\t// If we request fields but the result doesn't contain the fields,\n\t\t// explicitely set these fields as \"undefined\"\n\t\t// that way we consider the query \"fullfilled\".\n\t\tif ( query._fields ) {\n\t\t\trecords = records.map( ( record ) => {\n\t\t\t\tquery._fields.split( ',' ).forEach( ( field ) => {\n\t\t\t\t\tif ( ! record.hasOwnProperty( field ) ) {\n\t\t\t\t\t\trecord[ field ] = undefined;\n\t\t\t\t\t}\n\t\t\t\t} );\n\n\t\t\t\treturn record;\n\t\t\t} );\n\t\t}\n\n\t\tdispatch.receiveEntityRecords( kind, name, records, query );\n\n\t\t// When requesting all fields, the list of results can be used to\n\t\t// resolve the `getEntityRecord` selector in addition to `getEntityRecords`.\n\t\t// See https://github.com/WordPress/gutenberg/pull/26575\n\t\tif ( ! query?._fields && ! query.context ) {\n\t\t\tconst key = entityConfig.key || DEFAULT_ENTITY_KEY;\n\t\t\tconst resolutionsArgs = records\n\t\t\t\t.filter( ( record ) => record[ key ] )\n\t\t\t\t.map( ( record ) => [ kind, name, record[ key ] ] );\n\n\t\t\tdispatch( {\n\t\t\t\ttype: 'START_RESOLUTIONS',\n\t\t\t\tselectorName: 'getEntityRecord',\n\t\t\t\targs: resolutionsArgs,\n\t\t\t} );\n\t\t\tdispatch( {\n\t\t\t\ttype: 'FINISH_RESOLUTIONS',\n\t\t\t\tselectorName: 'getEntityRecord',\n\t\t\t\targs: resolutionsArgs,\n\t\t\t} );\n\t\t}\n\t} finally {\n\t\tdispatch.__unstableReleaseStoreLock( lock );\n\t}\n};\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 = () => async ( { dispatch, resolveSelect } ) => {\n\tconst activeThemes = await resolveSelect.getEntityRecords(\n\t\t'root',\n\t\t'theme',\n\t\t{ status: 'active' }\n\t);\n\n\tdispatch.receiveCurrentTheme( activeThemes[ 0 ] );\n};\n\n/**\n * Requests theme supports data from the index.\n */\nexport const getThemeSupports = forwardResolver( 'getCurrentTheme' );\n\n/**\n * Requests a preview from the from the Embed API.\n *\n * @param {string} url URL to get the preview for.\n */\nexport const getEmbedPreview = ( url ) => async ( { dispatch } ) => {\n\ttry {\n\t\tconst embedProxyResponse = await apiFetch( {\n\t\t\tpath: addQueryArgs( '/oembed/1.0/proxy', { url } ),\n\t\t} );\n\t\tdispatch.receiveEmbedPreview( url, embedProxyResponse );\n\t} catch ( error ) {\n\t\t// Embed API 404s if the URL cannot be embedded, so we have to catch the error from the apiRequest here.\n\t\tdispatch.receiveEmbedPreview( url, false );\n\t}\n};\n\n/**\n * Checks whether the current user can perform the given action on the given\n * REST resource.\n *\n * @param {string} action Action to check. One of: 'create', 'read', 'update',\n * 'delete'.\n * @param {string} resource REST resource to check, e.g. 'media' or 'posts'.\n * @param {?string} id ID of the rest resource to check.\n */\nexport const canUser = ( action, resource, id ) => async ( { dispatch } ) => {\n\tconst methods = {\n\t\tcreate: 'POST',\n\t\tread: 'GET',\n\t\tupdate: 'PUT',\n\t\tdelete: 'DELETE',\n\t};\n\n\tconst method = methods[ action ];\n\tif ( ! method ) {\n\t\tthrow new Error( `'${ action }' is not a valid action.` );\n\t}\n\n\tconst path = id ? `/wp/v2/${ resource }/${ id }` : `/wp/v2/${ resource }`;\n\n\tlet response;\n\ttry {\n\t\tresponse = await apiFetch( {\n\t\t\tpath,\n\t\t\tmethod: 'OPTIONS',\n\t\t\tparse: false,\n\t\t} );\n\t} catch ( error ) {\n\t\t// Do nothing if our OPTIONS request comes back with an API error (4xx or\n\t\t// 5xx). The previously determined isAllowed value will remain in the store.\n\t\treturn;\n\t}\n\n\t// Optional chaining operator is used here because the API requests don't\n\t// return the expected result in the native version. Instead, API requests\n\t// only return the result, without including response properties like the headers.\n\tconst allowHeader = response.headers?.get( 'allow' );\n\tconst key = compact( [ action, resource, id ] ).join( '/' );\n\tconst isAllowed = includes( allowHeader, method );\n\tdispatch.receiveUserPermission( key, isAllowed );\n};\n\n/**\n * Checks whether the current user can perform the given action on the given\n * REST resource.\n *\n * @param {string} kind Entity kind.\n * @param {string} name Entity name.\n * @param {string} recordId Record's id.\n */\nexport const canUserEditEntityRecord = ( kind, name, recordId ) => async ( {\n\tdispatch,\n} ) => {\n\tconst configs = await dispatch( getOrLoadEntitiesConfig( kind ) );\n\tconst entityConfig = find( configs, { kind, name } );\n\tif ( ! entityConfig ) {\n\t\treturn;\n\t}\n\n\tconst resource = entityConfig.__unstable_rest_base;\n\tawait dispatch( canUser( 'update', resource, recordId ) );\n};\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 = ( postType, postId ) => async ( {\n\tdispatch,\n\tresolveSelect,\n} ) => {\n\tconst { rest_base: restBase } = await resolveSelect.getPostType( postType );\n\tconst autosaves = await apiFetch( {\n\t\tpath: `/wp/v2/${ restBase }/${ postId }/autosaves?context=edit`,\n\t} );\n\n\tif ( autosaves && autosaves.length ) {\n\t\tdispatch.receiveAutosaves( postId, autosaves );\n\t}\n};\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 = ( postType, postId ) => async ( {\n\tresolveSelect,\n} ) => {\n\tawait resolveSelect.getAutosaves( postType, postId );\n};\n\n/**\n * Retrieve the frontend template used for a given link.\n *\n * @param {string} link Link.\n */\nexport const __experimentalGetTemplateForLink = ( link ) => async ( {\n\tdispatch,\n\tresolveSelect,\n} ) => {\n\t// Ideally this should be using an apiFetch call\n\t// We could potentially do so by adding a \"filter\" to the `wp_template` end point.\n\t// Also it seems the returned object is not a regular REST API post type.\n\tlet template;\n\ttry {\n\t\ttemplate = await window\n\t\t\t.fetch( addQueryArgs( link, { '_wp-find-template': true } ) )\n\t\t\t.then( ( res ) => res.json() )\n\t\t\t.then( ( { data } ) => data );\n\t} catch ( e ) {\n\t\t// For non-FSE themes, it is possible that this request returns an error.\n\t}\n\n\tif ( ! template ) {\n\t\treturn;\n\t}\n\n\tconst record = await resolveSelect.getEntityRecord(\n\t\t'postType',\n\t\t'wp_template',\n\t\ttemplate.id\n\t);\n\n\tif ( record ) {\n\t\tdispatch.receiveEntityRecords( 'postType', 'wp_template', [ record ], {\n\t\t\t'find-template': link,\n\t\t} );\n\t}\n};\n\n__experimentalGetTemplateForLink.shouldInvalidate = ( action ) => {\n\treturn (\n\t\t( action.type === 'RECEIVE_ITEMS' || action.type === 'REMOVE_ITEMS' ) &&\n\t\taction.invalidateCache &&\n\t\taction.kind === 'postType' &&\n\t\taction.name === 'wp_template'\n\t);\n};\n\nexport const __experimentalGetCurrentGlobalStylesId = () => async ( {\n\tdispatch,\n\tresolveSelect,\n} ) => {\n\tconst activeThemes = await resolveSelect.getEntityRecords(\n\t\t'root',\n\t\t'theme',\n\t\t{ status: 'active' }\n\t);\n\tconst globalStylesURL = get( activeThemes, [\n\t\t0,\n\t\t'_links',\n\t\t'wp:user-global-styles',\n\t\t0,\n\t\t'href',\n\t] );\n\tif ( globalStylesURL ) {\n\t\tconst globalStylesObject = await apiFetch( {\n\t\t\turl: globalStylesURL,\n\t\t} );\n\t\tdispatch.__experimentalReceiveCurrentGlobalStylesId(\n\t\t\tglobalStylesObject.id\n\t\t);\n\t}\n};\n\nexport const __experimentalGetCurrentThemeBaseGlobalStyles = () => async ( {\n\tresolveSelect,\n\tdispatch,\n} ) => {\n\tconst currentTheme = await resolveSelect.getCurrentTheme();\n\tconst themeGlobalStyles = await apiFetch( {\n\t\tpath: `/wp/v2/global-styles/themes/${ currentTheme.stylesheet }`,\n\t} );\n\tdispatch.__experimentalReceiveThemeBaseGlobalStyles(\n\t\tcurrentTheme.stylesheet,\n\t\tthemeGlobalStyles\n\t);\n};\n\nexport const __experimentalGetCurrentThemeGlobalStylesVariations = () => async ( {\n\tresolveSelect,\n\tdispatch,\n} ) => {\n\tconst currentTheme = await resolveSelect.getCurrentTheme();\n\tconst variations = await apiFetch( {\n\t\tpath: `/wp/v2/global-styles/themes/${ currentTheme.stylesheet }/variations`,\n\t} );\n\tdispatch.__experimentalReceiveThemeGlobalStyleVariations(\n\t\tcurrentTheme.stylesheet,\n\t\tvariations\n\t);\n};\n\nexport const getBlockPatterns = () => async ( { dispatch } ) => {\n\tconst patterns = await apiFetch( {\n\t\tpath: '/__experimental/block-patterns/patterns',\n\t} );\n\tdispatch( { type: 'RECEIVE_BLOCK_PATTERNS', patterns } );\n};\n\nexport const getBlockPatternCategories = () => async ( { dispatch } ) => {\n\tconst categories = await apiFetch( {\n\t\tpath: '/__experimental/block-patterns/categories',\n\t} );\n\tdispatch( { type: 'RECEIVE_BLOCK_PATTERN_CATEGORIES', categories } );\n};\n"]}
|
package/build/selectors.js
CHANGED
|
@@ -16,12 +16,16 @@ exports.canUserEditEntityRecord = canUserEditEntityRecord;
|
|
|
16
16
|
exports.getAuthors = getAuthors;
|
|
17
17
|
exports.getAutosave = getAutosave;
|
|
18
18
|
exports.getAutosaves = getAutosaves;
|
|
19
|
+
exports.getBlockPatternCategories = getBlockPatternCategories;
|
|
20
|
+
exports.getBlockPatterns = getBlockPatterns;
|
|
19
21
|
exports.getCurrentTheme = getCurrentTheme;
|
|
20
22
|
exports.getCurrentUser = getCurrentUser;
|
|
21
23
|
exports.getEditedEntityRecord = void 0;
|
|
22
24
|
exports.getEmbedPreview = getEmbedPreview;
|
|
23
25
|
exports.getEntitiesByKind = getEntitiesByKind;
|
|
26
|
+
exports.getEntitiesConfig = getEntitiesConfig;
|
|
24
27
|
exports.getEntity = getEntity;
|
|
28
|
+
exports.getEntityConfig = getEntityConfig;
|
|
25
29
|
exports.getEntityRecord = void 0;
|
|
26
30
|
exports.getEntityRecordEdits = getEntityRecordEdits;
|
|
27
31
|
exports.getEntityRecordNonTransientEdits = void 0;
|
|
@@ -144,8 +148,9 @@ const getUserQueryResults = (0, _rememo.default)((state, queryID) => {
|
|
|
144
148
|
return (0, _lodash.map)(queryResults, id => state.users.byId[id]);
|
|
145
149
|
}, (state, queryID) => [state.users.queries[queryID], state.users.byId]);
|
|
146
150
|
/**
|
|
147
|
-
* Returns
|
|
151
|
+
* Returns the loaded entities for the given kind.
|
|
148
152
|
*
|
|
153
|
+
* @deprecated since WordPress 6.0. Use getEntitiesConfig instead
|
|
149
154
|
* @param {Object} state Data state.
|
|
150
155
|
* @param {string} kind Entity kind.
|
|
151
156
|
*
|
|
@@ -155,22 +160,58 @@ const getUserQueryResults = (0, _rememo.default)((state, queryID) => {
|
|
|
155
160
|
exports.getUserQueryResults = getUserQueryResults;
|
|
156
161
|
|
|
157
162
|
function getEntitiesByKind(state, kind) {
|
|
163
|
+
(0, _deprecated.default)("wp.data.select( 'core' ).getEntitiesByKind()", {
|
|
164
|
+
since: '6.0',
|
|
165
|
+
alternative: "wp.data.select( 'core' ).getEntitiesConfig()"
|
|
166
|
+
});
|
|
167
|
+
return getEntitiesConfig(state, kind);
|
|
168
|
+
}
|
|
169
|
+
/**
|
|
170
|
+
* Returns the loaded entities for the given kind.
|
|
171
|
+
*
|
|
172
|
+
* @param {Object} state Data state.
|
|
173
|
+
* @param {string} kind Entity kind.
|
|
174
|
+
*
|
|
175
|
+
* @return {Array<Object>} Array of entities with config matching kind.
|
|
176
|
+
*/
|
|
177
|
+
|
|
178
|
+
|
|
179
|
+
function getEntitiesConfig(state, kind) {
|
|
158
180
|
return (0, _lodash.filter)(state.entities.config, {
|
|
159
181
|
kind
|
|
160
182
|
});
|
|
161
183
|
}
|
|
162
184
|
/**
|
|
163
|
-
* Returns the entity
|
|
185
|
+
* Returns the entity config given its kind and name.
|
|
164
186
|
*
|
|
187
|
+
* @deprecated since WordPress 6.0. Use getEntityConfig instead
|
|
165
188
|
* @param {Object} state Data state.
|
|
166
189
|
* @param {string} kind Entity kind.
|
|
167
190
|
* @param {string} name Entity name.
|
|
168
191
|
*
|
|
169
|
-
* @return {Object} Entity
|
|
192
|
+
* @return {Object} Entity config
|
|
170
193
|
*/
|
|
171
194
|
|
|
172
195
|
|
|
173
196
|
function getEntity(state, kind, name) {
|
|
197
|
+
(0, _deprecated.default)("wp.data.select( 'core' ).getEntity()", {
|
|
198
|
+
since: '6.0',
|
|
199
|
+
alternative: "wp.data.select( 'core' ).getEntityConfig()"
|
|
200
|
+
});
|
|
201
|
+
return getEntityConfig(state, kind, name);
|
|
202
|
+
}
|
|
203
|
+
/**
|
|
204
|
+
* Returns the entity config given its kind and name.
|
|
205
|
+
*
|
|
206
|
+
* @param {Object} state Data state.
|
|
207
|
+
* @param {string} kind Entity kind.
|
|
208
|
+
* @param {string} name Entity name.
|
|
209
|
+
*
|
|
210
|
+
* @return {Object} Entity config
|
|
211
|
+
*/
|
|
212
|
+
|
|
213
|
+
|
|
214
|
+
function getEntityConfig(state, kind, name) {
|
|
174
215
|
return (0, _lodash.find)(state.entities.config, {
|
|
175
216
|
kind,
|
|
176
217
|
name
|
|
@@ -187,14 +228,14 @@ function getEntity(state, kind, name) {
|
|
|
187
228
|
* @param {number} key Record's key
|
|
188
229
|
* @param {?Object} query Optional query.
|
|
189
230
|
*
|
|
190
|
-
* @return {Object
|
|
231
|
+
* @return {Object|undefined} Record.
|
|
191
232
|
*/
|
|
192
233
|
|
|
193
234
|
|
|
194
235
|
const getEntityRecord = (0, _rememo.default)((state, kind, name, key, query) => {
|
|
195
236
|
var _query$context, _queriedState$items$c;
|
|
196
237
|
|
|
197
|
-
const queriedState = (0, _lodash.get)(state.entities.
|
|
238
|
+
const queriedState = (0, _lodash.get)(state.entities.records, [kind, name, 'queriedData']);
|
|
198
239
|
|
|
199
240
|
if (!queriedState) {
|
|
200
241
|
return undefined;
|
|
@@ -216,8 +257,10 @@ const getEntityRecord = (0, _rememo.default)((state, kind, name, key, query) =>
|
|
|
216
257
|
const item = (_queriedState$items$c = queriedState.items[context]) === null || _queriedState$items$c === void 0 ? void 0 : _queriedState$items$c[key];
|
|
217
258
|
|
|
218
259
|
if (item && query._fields) {
|
|
260
|
+
var _getNormalizedCommaSe;
|
|
261
|
+
|
|
219
262
|
const filteredItem = {};
|
|
220
|
-
const fields = (0, _utils.getNormalizedCommaSeparable)(query._fields);
|
|
263
|
+
const fields = (_getNormalizedCommaSe = (0, _utils.getNormalizedCommaSeparable)(query._fields)) !== null && _getNormalizedCommaSe !== void 0 ? _getNormalizedCommaSe : [];
|
|
221
264
|
|
|
222
265
|
for (let f = 0; f < fields.length; f++) {
|
|
223
266
|
const field = fields[f].split('.');
|
|
@@ -233,10 +276,10 @@ const getEntityRecord = (0, _rememo.default)((state, kind, name, key, query) =>
|
|
|
233
276
|
var _query$context2;
|
|
234
277
|
|
|
235
278
|
const context = (_query$context2 = query === null || query === void 0 ? void 0 : query.context) !== null && _query$context2 !== void 0 ? _query$context2 : 'default';
|
|
236
|
-
return [(0, _lodash.get)(state.entities.
|
|
279
|
+
return [(0, _lodash.get)(state.entities.records, [kind, name, 'queriedData', 'items', context, recordId]), (0, _lodash.get)(state.entities.records, [kind, name, 'queriedData', 'itemIsComplete', context, recordId])];
|
|
237
280
|
});
|
|
238
281
|
/**
|
|
239
|
-
* Returns the Entity's record object by key. Doesn't trigger a resolver nor requests the entity from the API if the entity record isn't available in the local state.
|
|
282
|
+
* Returns the Entity's record object by key. Doesn't trigger a resolver nor requests the entity records from the API if the entity record isn't available in the local state.
|
|
240
283
|
*
|
|
241
284
|
* @param {Object} state State tree
|
|
242
285
|
* @param {string} kind Entity kind.
|
|
@@ -267,7 +310,7 @@ function __experimentalGetEntityRecordNoResolver(state, kind, name, key) {
|
|
|
267
310
|
const getRawEntityRecord = (0, _rememo.default)((state, kind, name, key) => {
|
|
268
311
|
const record = getEntityRecord(state, kind, name, key);
|
|
269
312
|
return record && Object.keys(record).reduce((accumulator, _key) => {
|
|
270
|
-
if ((0, _utils.isRawAttribute)(
|
|
313
|
+
if ((0, _utils.isRawAttribute)(getEntityConfig(state, kind, name), _key)) {
|
|
271
314
|
// Because edits are the "raw" attribute values,
|
|
272
315
|
// we return those from record selectors to make rendering,
|
|
273
316
|
// comparisons, and joins with edits easier.
|
|
@@ -282,7 +325,7 @@ const getRawEntityRecord = (0, _rememo.default)((state, kind, name, key) => {
|
|
|
282
325
|
var _query$context3;
|
|
283
326
|
|
|
284
327
|
const context = (_query$context3 = query === null || query === void 0 ? void 0 : query.context) !== null && _query$context3 !== void 0 ? _query$context3 : 'default';
|
|
285
|
-
return [state.entities.config, (0, _lodash.get)(state.entities.
|
|
328
|
+
return [state.entities.config, (0, _lodash.get)(state.entities.records, [kind, name, 'queriedData', 'items', context, recordId]), (0, _lodash.get)(state.entities.records, [kind, name, 'queriedData', 'itemIsComplete', context, recordId])];
|
|
286
329
|
});
|
|
287
330
|
/**
|
|
288
331
|
* Returns true if records have been received for the given set of parameters,
|
|
@@ -316,7 +359,7 @@ function hasEntityRecords(state, kind, name, query) {
|
|
|
316
359
|
function getEntityRecords(state, kind, name, query) {
|
|
317
360
|
// Queried data state is prepopulated for all known entities. If this is not
|
|
318
361
|
// assigned for the given parameters, then it is known to not exist.
|
|
319
|
-
const queriedState = (0, _lodash.get)(state.entities.
|
|
362
|
+
const queriedState = (0, _lodash.get)(state.entities.records, [kind, name, 'queriedData']);
|
|
320
363
|
|
|
321
364
|
if (!queriedState) {
|
|
322
365
|
return null;
|
|
@@ -336,27 +379,27 @@ function getEntityRecords(state, kind, name, query) {
|
|
|
336
379
|
const __experimentalGetDirtyEntityRecords = (0, _rememo.default)(state => {
|
|
337
380
|
const {
|
|
338
381
|
entities: {
|
|
339
|
-
|
|
382
|
+
records
|
|
340
383
|
}
|
|
341
384
|
} = state;
|
|
342
385
|
const dirtyRecords = [];
|
|
343
|
-
Object.keys(
|
|
344
|
-
Object.keys(
|
|
345
|
-
const primaryKeys = Object.keys(
|
|
386
|
+
Object.keys(records).forEach(kind => {
|
|
387
|
+
Object.keys(records[kind]).forEach(name => {
|
|
388
|
+
const primaryKeys = Object.keys(records[kind][name].edits).filter(primaryKey => // The entity record must exist (not be deleted),
|
|
346
389
|
// and it must have edits.
|
|
347
390
|
getEntityRecord(state, kind, name, primaryKey) && hasEditsForEntityRecord(state, kind, name, primaryKey));
|
|
348
391
|
|
|
349
392
|
if (primaryKeys.length) {
|
|
350
|
-
const
|
|
393
|
+
const entityConfig = getEntityConfig(state, kind, name);
|
|
351
394
|
primaryKeys.forEach(primaryKey => {
|
|
352
|
-
var
|
|
395
|
+
var _entityConfig$getTitl;
|
|
353
396
|
|
|
354
397
|
const entityRecord = getEditedEntityRecord(state, kind, name, primaryKey);
|
|
355
398
|
dirtyRecords.push({
|
|
356
399
|
// We avoid using primaryKey because it's transformed into a string
|
|
357
400
|
// when it's used as an object key.
|
|
358
|
-
key: entityRecord[
|
|
359
|
-
title: (
|
|
401
|
+
key: entityRecord[entityConfig.key || _entities.DEFAULT_ENTITY_KEY],
|
|
402
|
+
title: (entityConfig === null || entityConfig === void 0 ? void 0 : (_entityConfig$getTitl = entityConfig.getTitle) === null || _entityConfig$getTitl === void 0 ? void 0 : _entityConfig$getTitl.call(entityConfig, entityRecord)) || '',
|
|
360
403
|
name,
|
|
361
404
|
kind
|
|
362
405
|
});
|
|
@@ -365,7 +408,7 @@ const __experimentalGetDirtyEntityRecords = (0, _rememo.default)(state => {
|
|
|
365
408
|
});
|
|
366
409
|
});
|
|
367
410
|
return dirtyRecords;
|
|
368
|
-
}, state => [state.entities.
|
|
411
|
+
}, state => [state.entities.records]);
|
|
369
412
|
/**
|
|
370
413
|
* Returns the list of entities currently being saved.
|
|
371
414
|
*
|
|
@@ -380,25 +423,25 @@ exports.__experimentalGetDirtyEntityRecords = __experimentalGetDirtyEntityRecord
|
|
|
380
423
|
const __experimentalGetEntitiesBeingSaved = (0, _rememo.default)(state => {
|
|
381
424
|
const {
|
|
382
425
|
entities: {
|
|
383
|
-
|
|
426
|
+
records
|
|
384
427
|
}
|
|
385
428
|
} = state;
|
|
386
429
|
const recordsBeingSaved = [];
|
|
387
|
-
Object.keys(
|
|
388
|
-
Object.keys(
|
|
389
|
-
const primaryKeys = Object.keys(
|
|
430
|
+
Object.keys(records).forEach(kind => {
|
|
431
|
+
Object.keys(records[kind]).forEach(name => {
|
|
432
|
+
const primaryKeys = Object.keys(records[kind][name].saving).filter(primaryKey => isSavingEntityRecord(state, kind, name, primaryKey));
|
|
390
433
|
|
|
391
434
|
if (primaryKeys.length) {
|
|
392
|
-
const
|
|
435
|
+
const entityConfig = getEntityConfig(state, kind, name);
|
|
393
436
|
primaryKeys.forEach(primaryKey => {
|
|
394
|
-
var
|
|
437
|
+
var _entityConfig$getTitl2;
|
|
395
438
|
|
|
396
439
|
const entityRecord = getEditedEntityRecord(state, kind, name, primaryKey);
|
|
397
440
|
recordsBeingSaved.push({
|
|
398
441
|
// We avoid using primaryKey because it's transformed into a string
|
|
399
442
|
// when it's used as an object key.
|
|
400
|
-
key: entityRecord[
|
|
401
|
-
title: (
|
|
443
|
+
key: entityRecord[entityConfig.key || _entities.DEFAULT_ENTITY_KEY],
|
|
444
|
+
title: (entityConfig === null || entityConfig === void 0 ? void 0 : (_entityConfig$getTitl2 = entityConfig.getTitle) === null || _entityConfig$getTitl2 === void 0 ? void 0 : _entityConfig$getTitl2.call(entityConfig, entityRecord)) || '',
|
|
402
445
|
name,
|
|
403
446
|
kind
|
|
404
447
|
});
|
|
@@ -407,7 +450,7 @@ const __experimentalGetEntitiesBeingSaved = (0, _rememo.default)(state => {
|
|
|
407
450
|
});
|
|
408
451
|
});
|
|
409
452
|
return recordsBeingSaved;
|
|
410
|
-
}, state => [state.entities.
|
|
453
|
+
}, state => [state.entities.records]);
|
|
411
454
|
/**
|
|
412
455
|
* Returns the specified entity record's edits.
|
|
413
456
|
*
|
|
@@ -423,7 +466,7 @@ const __experimentalGetEntitiesBeingSaved = (0, _rememo.default)(state => {
|
|
|
423
466
|
exports.__experimentalGetEntitiesBeingSaved = __experimentalGetEntitiesBeingSaved;
|
|
424
467
|
|
|
425
468
|
function getEntityRecordEdits(state, kind, name, recordId) {
|
|
426
|
-
return (0, _lodash.get)(state.entities.
|
|
469
|
+
return (0, _lodash.get)(state.entities.records, [kind, name, 'edits', recordId]);
|
|
427
470
|
}
|
|
428
471
|
/**
|
|
429
472
|
* Returns the specified entity record's non transient edits.
|
|
@@ -444,7 +487,7 @@ function getEntityRecordEdits(state, kind, name, recordId) {
|
|
|
444
487
|
const getEntityRecordNonTransientEdits = (0, _rememo.default)((state, kind, name, recordId) => {
|
|
445
488
|
const {
|
|
446
489
|
transientEdits
|
|
447
|
-
} =
|
|
490
|
+
} = getEntityConfig(state, kind, name) || {};
|
|
448
491
|
const edits = getEntityRecordEdits(state, kind, name, recordId) || {};
|
|
449
492
|
|
|
450
493
|
if (!transientEdits) {
|
|
@@ -458,15 +501,15 @@ const getEntityRecordNonTransientEdits = (0, _rememo.default)((state, kind, name
|
|
|
458
501
|
|
|
459
502
|
return acc;
|
|
460
503
|
}, {});
|
|
461
|
-
}, (state, kind, name, recordId) => [state.entities.config, (0, _lodash.get)(state.entities.
|
|
504
|
+
}, (state, kind, name, recordId) => [state.entities.config, (0, _lodash.get)(state.entities.records, [kind, name, 'edits', recordId])]);
|
|
462
505
|
/**
|
|
463
506
|
* Returns true if the specified entity record has edits,
|
|
464
507
|
* and false otherwise.
|
|
465
508
|
*
|
|
466
|
-
* @param {Object}
|
|
467
|
-
* @param {string}
|
|
468
|
-
* @param {string}
|
|
469
|
-
* @param {number} recordId Record ID.
|
|
509
|
+
* @param {Object} state State tree.
|
|
510
|
+
* @param {string} kind Entity kind.
|
|
511
|
+
* @param {string} name Entity name.
|
|
512
|
+
* @param {number|string} recordId Record ID.
|
|
470
513
|
*
|
|
471
514
|
* @return {boolean} Whether the entity record has edits or not.
|
|
472
515
|
*/
|
|
@@ -479,10 +522,10 @@ function hasEditsForEntityRecord(state, kind, name, recordId) {
|
|
|
479
522
|
/**
|
|
480
523
|
* Returns the specified entity record, merged with its edits.
|
|
481
524
|
*
|
|
482
|
-
* @param {Object}
|
|
483
|
-
* @param {string}
|
|
484
|
-
* @param {string}
|
|
485
|
-
* @param {number} recordId Record ID.
|
|
525
|
+
* @param {Object} state State tree.
|
|
526
|
+
* @param {string} kind Entity kind.
|
|
527
|
+
* @param {string} name Entity name.
|
|
528
|
+
* @param {number|string} recordId Record ID.
|
|
486
529
|
*
|
|
487
530
|
* @return {Object?} The entity record, merged with its edits.
|
|
488
531
|
*/
|
|
@@ -494,7 +537,7 @@ const getEditedEntityRecord = (0, _rememo.default)((state, kind, name, recordId)
|
|
|
494
537
|
var _query$context4;
|
|
495
538
|
|
|
496
539
|
const context = (_query$context4 = query === null || query === void 0 ? void 0 : query.context) !== null && _query$context4 !== void 0 ? _query$context4 : 'default';
|
|
497
|
-
return [state.entities.config, (0, _lodash.get)(state.entities.
|
|
540
|
+
return [state.entities.config, (0, _lodash.get)(state.entities.records, [kind, name, 'queriedData', 'items', context, recordId]), (0, _lodash.get)(state.entities.records, [kind, name, 'queriedData', 'itemIsComplete', context, recordId]), (0, _lodash.get)(state.entities.records, [kind, name, 'edits', recordId])];
|
|
498
541
|
});
|
|
499
542
|
/**
|
|
500
543
|
* Returns true if the specified entity record is autosaving, and false otherwise.
|
|
@@ -513,23 +556,23 @@ function isAutosavingEntityRecord(state, kind, name, recordId) {
|
|
|
513
556
|
const {
|
|
514
557
|
pending,
|
|
515
558
|
isAutosave
|
|
516
|
-
} = (0, _lodash.get)(state.entities.
|
|
559
|
+
} = (0, _lodash.get)(state.entities.records, [kind, name, 'saving', recordId], {});
|
|
517
560
|
return Boolean(pending && isAutosave);
|
|
518
561
|
}
|
|
519
562
|
/**
|
|
520
563
|
* Returns true if the specified entity record is saving, and false otherwise.
|
|
521
564
|
*
|
|
522
|
-
* @param {Object}
|
|
523
|
-
* @param {string}
|
|
524
|
-
* @param {string}
|
|
525
|
-
* @param {number} recordId Record ID.
|
|
565
|
+
* @param {Object} state State tree.
|
|
566
|
+
* @param {string} kind Entity kind.
|
|
567
|
+
* @param {string} name Entity name.
|
|
568
|
+
* @param {number|string} recordId Record ID.
|
|
526
569
|
*
|
|
527
570
|
* @return {boolean} Whether the entity record is saving or not.
|
|
528
571
|
*/
|
|
529
572
|
|
|
530
573
|
|
|
531
574
|
function isSavingEntityRecord(state, kind, name, recordId) {
|
|
532
|
-
return (0, _lodash.get)(state.entities.
|
|
575
|
+
return (0, _lodash.get)(state.entities.records, [kind, name, 'saving', recordId, 'pending'], false);
|
|
533
576
|
}
|
|
534
577
|
/**
|
|
535
578
|
* Returns true if the specified entity record is deleting, and false otherwise.
|
|
@@ -544,7 +587,7 @@ function isSavingEntityRecord(state, kind, name, recordId) {
|
|
|
544
587
|
|
|
545
588
|
|
|
546
589
|
function isDeletingEntityRecord(state, kind, name, recordId) {
|
|
547
|
-
return (0, _lodash.get)(state.entities.
|
|
590
|
+
return (0, _lodash.get)(state.entities.records, [kind, name, 'deleting', recordId, 'pending'], false);
|
|
548
591
|
}
|
|
549
592
|
/**
|
|
550
593
|
* Returns the specified entity record's last save error.
|
|
@@ -559,7 +602,7 @@ function isDeletingEntityRecord(state, kind, name, recordId) {
|
|
|
559
602
|
|
|
560
603
|
|
|
561
604
|
function getLastEntitySaveError(state, kind, name, recordId) {
|
|
562
|
-
return (0, _lodash.get)(state.entities.
|
|
605
|
+
return (0, _lodash.get)(state.entities.records, [kind, name, 'saving', recordId, 'error']);
|
|
563
606
|
}
|
|
564
607
|
/**
|
|
565
608
|
* Returns the specified entity record's last delete error.
|
|
@@ -574,7 +617,7 @@ function getLastEntitySaveError(state, kind, name, recordId) {
|
|
|
574
617
|
|
|
575
618
|
|
|
576
619
|
function getLastEntityDeleteError(state, kind, name, recordId) {
|
|
577
|
-
return (0, _lodash.get)(state.entities.
|
|
620
|
+
return (0, _lodash.get)(state.entities.records, [kind, name, 'deleting', recordId, 'error']);
|
|
578
621
|
}
|
|
579
622
|
/**
|
|
580
623
|
* Returns the current undo offset for the
|
|
@@ -760,13 +803,13 @@ function canUser(state, action, resource, id) {
|
|
|
760
803
|
|
|
761
804
|
|
|
762
805
|
function canUserEditEntityRecord(state, kind, name, recordId) {
|
|
763
|
-
const
|
|
806
|
+
const entityConfig = getEntityConfig(state, kind, name);
|
|
764
807
|
|
|
765
|
-
if (!
|
|
808
|
+
if (!entityConfig) {
|
|
766
809
|
return false;
|
|
767
810
|
}
|
|
768
811
|
|
|
769
|
-
const resource =
|
|
812
|
+
const resource = entityConfig.__unstable_rest_base;
|
|
770
813
|
return canUser(state, 'update', resource, recordId);
|
|
771
814
|
}
|
|
772
815
|
/**
|
|
@@ -871,7 +914,7 @@ function __experimentalGetTemplateForLink(state, link) {
|
|
|
871
914
|
*
|
|
872
915
|
* @param {Object} state Editor state.
|
|
873
916
|
*
|
|
874
|
-
* @return {Object
|
|
917
|
+
* @return {Object|null} The Global Styles object.
|
|
875
918
|
*/
|
|
876
919
|
|
|
877
920
|
|
|
@@ -889,7 +932,7 @@ function __experimentalGetCurrentThemeBaseGlobalStyles(state) {
|
|
|
889
932
|
*
|
|
890
933
|
* @param {Object} state Data state.
|
|
891
934
|
*
|
|
892
|
-
* @return {string} The current global styles ID.
|
|
935
|
+
* @return {string|null} The current global styles ID.
|
|
893
936
|
*/
|
|
894
937
|
|
|
895
938
|
|
|
@@ -902,4 +945,28 @@ function __experimentalGetCurrentThemeGlobalStylesVariations(state) {
|
|
|
902
945
|
|
|
903
946
|
return state.themeGlobalStyleVariations[currentTheme.stylesheet];
|
|
904
947
|
}
|
|
948
|
+
/**
|
|
949
|
+
* Retrieve the list of registered block patterns.
|
|
950
|
+
*
|
|
951
|
+
* @param {Object} state Data state.
|
|
952
|
+
*
|
|
953
|
+
* @return {Array} Block pattern list.
|
|
954
|
+
*/
|
|
955
|
+
|
|
956
|
+
|
|
957
|
+
function getBlockPatterns(state) {
|
|
958
|
+
return state.blockPatterns;
|
|
959
|
+
}
|
|
960
|
+
/**
|
|
961
|
+
* Retrieve the list of registered block pattern categories.
|
|
962
|
+
*
|
|
963
|
+
* @param {Object} state Data state.
|
|
964
|
+
*
|
|
965
|
+
* @return {Array} Block pattern category list.
|
|
966
|
+
*/
|
|
967
|
+
|
|
968
|
+
|
|
969
|
+
function getBlockPatternCategories(state) {
|
|
970
|
+
return state.blockPatternCategories;
|
|
971
|
+
}
|
|
905
972
|
//# sourceMappingURL=selectors.js.map
|