@wordpress/core-data 4.1.0 → 4.1.2
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 +6 -0
- package/README.md +9 -3
- package/build/actions.js +1 -1
- package/build/actions.js.map +1 -1
- package/build/hooks/constants.js +18 -0
- package/build/hooks/constants.js.map +1 -0
- package/build/hooks/memoize.js +18 -0
- package/build/hooks/memoize.js.map +1 -0
- package/build/hooks/use-entity-record.js +60 -0
- package/build/hooks/use-entity-record.js.map +1 -0
- package/build/hooks/use-entity-records.js +67 -0
- package/build/hooks/use-entity-records.js.map +1 -0
- package/build/hooks/use-query-select.js +130 -0
- package/build/hooks/use-query-select.js.map +1 -0
- package/build/index.js +34 -3
- package/build/index.js.map +1 -1
- package/build/resolvers.js +2 -17
- package/build/resolvers.js.map +1 -1
- package/build/types/attachment.js +6 -0
- package/build/types/attachment.js.map +1 -0
- package/build/types/base-entity-types.js +47 -0
- package/build/types/base-entity-types.js.map +1 -0
- package/build/types/comment.js +6 -0
- package/build/types/comment.js.map +1 -0
- package/build/types/helpers.js +6 -0
- package/build/types/helpers.js.map +1 -0
- package/build/types/index.js +6 -0
- package/build/types/index.js.map +1 -0
- package/build/types/menu-location.js +6 -0
- package/build/types/menu-location.js.map +1 -0
- package/build/types/nav-menu-item.js +6 -0
- package/build/types/nav-menu-item.js.map +1 -0
- package/build/types/nav-menu.js +6 -0
- package/build/types/nav-menu.js.map +1 -0
- package/build/types/navigation-area.js +6 -0
- package/build/types/navigation-area.js.map +1 -0
- package/build/types/page.js +6 -0
- package/build/types/page.js.map +1 -0
- package/build/types/plugin.js +6 -0
- package/build/types/plugin.js.map +1 -0
- package/build/types/post.js +6 -0
- package/build/types/post.js.map +1 -0
- package/build/types/settings.js +6 -0
- package/build/types/settings.js.map +1 -0
- package/build/types/sidebar.js +6 -0
- package/build/types/sidebar.js.map +1 -0
- package/build/types/taxonomy.js +6 -0
- package/build/types/taxonomy.js.map +1 -0
- package/build/types/theme.js +6 -0
- package/build/types/theme.js.map +1 -0
- package/build/types/type.js +6 -0
- package/build/types/type.js.map +1 -0
- package/build/types/user.js +6 -0
- package/build/types/user.js.map +1 -0
- package/build/types/widget-type.js +6 -0
- package/build/types/widget-type.js.map +1 -0
- package/build/types/widget.js +6 -0
- package/build/types/widget.js.map +1 -0
- package/build/types/wp-template-part.js +6 -0
- package/build/types/wp-template-part.js.map +1 -0
- package/build/types/wp-template.js +6 -0
- package/build/types/wp-template.js.map +1 -0
- package/build-module/actions.js +1 -1
- package/build-module/actions.js.map +1 -1
- package/build-module/hooks/constants.js +10 -0
- package/build-module/hooks/constants.js.map +1 -0
- package/build-module/hooks/memoize.js +7 -0
- package/build-module/hooks/memoize.js.map +1 -0
- package/build-module/hooks/use-entity-record.js +49 -0
- package/build-module/hooks/use-entity-record.js.map +1 -0
- package/build-module/hooks/use-entity-records.js +56 -0
- package/build-module/hooks/use-entity-records.js.map +1 -0
- package/build-module/hooks/use-query-select.js +116 -0
- package/build-module/hooks/use-query-select.js.map +1 -0
- package/build-module/index.js +4 -2
- package/build-module/index.js.map +1 -1
- package/build-module/resolvers.js +3 -18
- package/build-module/resolvers.js.map +1 -1
- package/build-module/types/attachment.js +2 -0
- package/build-module/types/attachment.js.map +1 -0
- package/build-module/types/base-entity-types.js +39 -0
- package/build-module/types/base-entity-types.js.map +1 -0
- package/build-module/types/comment.js +2 -0
- package/build-module/types/comment.js.map +1 -0
- package/build-module/types/helpers.js +2 -0
- package/build-module/types/helpers.js.map +1 -0
- package/build-module/types/index.js +2 -0
- package/build-module/types/index.js.map +1 -0
- package/build-module/types/menu-location.js +2 -0
- package/build-module/types/menu-location.js.map +1 -0
- package/build-module/types/nav-menu-item.js +2 -0
- package/build-module/types/nav-menu-item.js.map +1 -0
- package/build-module/types/nav-menu.js +2 -0
- package/build-module/types/nav-menu.js.map +1 -0
- package/build-module/types/navigation-area.js +2 -0
- package/build-module/types/navigation-area.js.map +1 -0
- package/build-module/types/page.js +2 -0
- package/build-module/types/page.js.map +1 -0
- package/build-module/types/plugin.js +2 -0
- package/build-module/types/plugin.js.map +1 -0
- package/build-module/types/post.js +2 -0
- package/build-module/types/post.js.map +1 -0
- package/build-module/types/settings.js +2 -0
- package/build-module/types/settings.js.map +1 -0
- package/build-module/types/sidebar.js +2 -0
- package/build-module/types/sidebar.js.map +1 -0
- package/build-module/types/taxonomy.js +2 -0
- package/build-module/types/taxonomy.js.map +1 -0
- package/build-module/types/theme.js +2 -0
- package/build-module/types/theme.js.map +1 -0
- package/build-module/types/type.js +2 -0
- package/build-module/types/type.js.map +1 -0
- package/build-module/types/user.js +2 -0
- package/build-module/types/user.js.map +1 -0
- package/build-module/types/widget-type.js +2 -0
- package/build-module/types/widget-type.js.map +1 -0
- package/build-module/types/widget.js +2 -0
- package/build-module/types/widget.js.map +1 -0
- package/build-module/types/wp-template-part.js +2 -0
- package/build-module/types/wp-template-part.js.map +1 -0
- package/build-module/types/wp-template.js +2 -0
- package/build-module/types/wp-template.js.map +1 -0
- package/package.json +12 -11
- package/src/actions.js +1 -1
- package/src/hooks/constants.ts +7 -0
- package/src/hooks/memoize.js +7 -0
- package/src/hooks/test/use-entity-record.js +74 -0
- package/src/hooks/test/use-entity-records.js +78 -0
- package/src/hooks/test/use-query-select.js +194 -0
- package/src/hooks/use-entity-record.ts +72 -0
- package/src/hooks/use-entity-records.ts +79 -0
- package/src/hooks/use-query-select.ts +131 -0
- package/src/index.js +3 -1
- package/src/resolvers.js +3 -17
- package/src/test/resolvers.js +4 -10
- package/src/types/README.md +193 -0
- package/src/types/attachment.ts +146 -0
- package/src/types/base-entity-types.ts +36 -0
- package/src/types/comment.ts +96 -0
- package/src/types/helpers.ts +153 -0
- package/src/types/index.ts +72 -0
- package/src/types/menu-location.ts +29 -0
- package/src/types/nav-menu-item.ts +106 -0
- package/src/types/nav-menu.ts +53 -0
- package/src/types/navigation-area.ts +29 -0
- package/src/types/page.ts +144 -0
- package/src/types/plugin.ts +74 -0
- package/src/types/post.ts +153 -0
- package/src/types/settings.ts +93 -0
- package/src/types/sidebar.ts +60 -0
- package/src/types/taxonomy.ts +92 -0
- package/src/types/theme.ts +222 -0
- package/src/types/type.ts +80 -0
- package/src/types/user.ts +109 -0
- package/src/types/widget-type.ts +37 -0
- package/src/types/widget.ts +64 -0
- package/src/types/wp-template-part.ts +94 -0
- package/src/types/wp-template.ts +94 -0
package/build/index.js
CHANGED
|
@@ -7,7 +7,9 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
7
7
|
});
|
|
8
8
|
var _exportNames = {
|
|
9
9
|
store: true,
|
|
10
|
-
EntityProvider: true
|
|
10
|
+
EntityProvider: true,
|
|
11
|
+
__experimentalUseEntityRecord: true,
|
|
12
|
+
__experimentalUseEntityRecords: true
|
|
11
13
|
};
|
|
12
14
|
Object.defineProperty(exports, "EntityProvider", {
|
|
13
15
|
enumerable: true,
|
|
@@ -15,6 +17,18 @@ Object.defineProperty(exports, "EntityProvider", {
|
|
|
15
17
|
return _entityProvider.default;
|
|
16
18
|
}
|
|
17
19
|
});
|
|
20
|
+
Object.defineProperty(exports, "__experimentalUseEntityRecord", {
|
|
21
|
+
enumerable: true,
|
|
22
|
+
get: function () {
|
|
23
|
+
return _useEntityRecord.default;
|
|
24
|
+
}
|
|
25
|
+
});
|
|
26
|
+
Object.defineProperty(exports, "__experimentalUseEntityRecords", {
|
|
27
|
+
enumerable: true,
|
|
28
|
+
get: function () {
|
|
29
|
+
return _useEntityRecords.default;
|
|
30
|
+
}
|
|
31
|
+
});
|
|
18
32
|
exports.store = void 0;
|
|
19
33
|
|
|
20
34
|
var _data = require("@wordpress/data");
|
|
@@ -47,6 +61,10 @@ Object.keys(_entityProvider).forEach(function (key) {
|
|
|
47
61
|
});
|
|
48
62
|
});
|
|
49
63
|
|
|
64
|
+
var _useEntityRecord = _interopRequireDefault(require("./hooks/use-entity-record"));
|
|
65
|
+
|
|
66
|
+
var _useEntityRecords = _interopRequireDefault(require("./hooks/use-entity-records"));
|
|
67
|
+
|
|
50
68
|
var _fetch = require("./fetch");
|
|
51
69
|
|
|
52
70
|
Object.keys(_fetch).forEach(function (key) {
|
|
@@ -61,6 +79,20 @@ Object.keys(_fetch).forEach(function (key) {
|
|
|
61
79
|
});
|
|
62
80
|
});
|
|
63
81
|
|
|
82
|
+
var _types = require("./types");
|
|
83
|
+
|
|
84
|
+
Object.keys(_types).forEach(function (key) {
|
|
85
|
+
if (key === "default" || key === "__esModule") return;
|
|
86
|
+
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
87
|
+
if (key in exports && exports[key] === _types[key]) return;
|
|
88
|
+
Object.defineProperty(exports, key, {
|
|
89
|
+
enumerable: true,
|
|
90
|
+
get: function () {
|
|
91
|
+
return _types[key];
|
|
92
|
+
}
|
|
93
|
+
});
|
|
94
|
+
});
|
|
95
|
+
|
|
64
96
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
65
97
|
|
|
66
98
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
@@ -148,8 +180,7 @@ const storeConfig = () => ({
|
|
|
148
180
|
},
|
|
149
181
|
resolvers: { ...resolvers,
|
|
150
182
|
...entityResolvers
|
|
151
|
-
}
|
|
152
|
-
__experimentalUseThunks: true
|
|
183
|
+
}
|
|
153
184
|
});
|
|
154
185
|
/**
|
|
155
186
|
* Store definition for the code data namespace.
|
package/build/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/core-data/src/index.js"],"names":["entitySelectors","defaultEntities","reduce","result","entity","kind","name","state","key","query","selectors","getEntityRecord","args","getEntityRecords","entityResolvers","resolvers","pluralMethodName","shouldInvalidate","action","entityActions","actions","saveEntityRecord","deleteEntityRecord","storeConfig","reducer","
|
|
1
|
+
{"version":3,"sources":["@wordpress/core-data/src/index.js"],"names":["entitySelectors","defaultEntities","reduce","result","entity","kind","name","state","key","query","selectors","getEntityRecord","args","getEntityRecords","entityResolvers","resolvers","pluralMethodName","shouldInvalidate","action","entityActions","actions","saveEntityRecord","deleteEntityRecord","storeConfig","reducer","store","STORE_NAME"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAGA;;AAKA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AA4DA;;AAGA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AAFA;;AACA;;AAEA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AACA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;;;;AA/EA;AACA;AACA;;AAGA;AACA;AACA;AASA;AACA;AACA;AACA;AAEA,MAAMA,eAAe,GAAGC,0BAAgBC,MAAhB,CAAwB,CAAEC,MAAF,EAAUC,MAAV,KAAsB;AACrE,QAAM;AAAEC,IAAAA,IAAF;AAAQC,IAAAA;AAAR,MAAiBF,MAAvB;;AACAD,EAAAA,MAAM,CAAE,6BAAeE,IAAf,EAAqBC,IAArB,CAAF,CAAN,GAAw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WAAW,EAAzC,CAAd;;AAEP,oBAAUE,KAAV","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { createReduxStore, register } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport reducer from './reducer';\nimport * as selectors from './selectors';\nimport * as actions from './actions';\nimport * as resolvers from './resolvers';\nimport createLocksActions from './locks/actions';\nimport { defaultEntities, getMethodName } from './entities';\nimport { STORE_NAME } from './name';\n\n// The entity selectors/resolvers and actions are shortcuts to their generic equivalents\n// (getEntityRecord, getEntityRecords, updateEntityRecord, updateEntityRecordss)\n// Instead of getEntityRecord, the consumer could use more user-frieldly named selector: getPostType, getTaxonomy...\n// The \"kind\" and the \"name\" of the entity are combined to generate these shortcuts.\n\nconst entitySelectors = defaultEntities.reduce( ( result, entity ) => {\n\tconst { kind, name } = entity;\n\tresult[ getMethodName( kind, name ) ] = ( state, key, query ) =>\n\t\tselectors.getEntityRecord( state, kind, name, key, query );\n\tresult[ getMethodName( kind, name, 'get', true ) ] = ( state, ...args ) =>\n\t\tselectors.getEntityRecords( state, kind, name, ...args );\n\treturn result;\n}, {} );\n\nconst entityResolvers = defaultEntities.reduce( ( result, entity ) => {\n\tconst { kind, name } = entity;\n\tresult[ getMethodName( kind, name ) ] = ( key, query ) =>\n\t\tresolvers.getEntityRecord( kind, name, key, query );\n\tconst pluralMethodName = getMethodName( kind, name, 'get', true );\n\tresult[ pluralMethodName ] = ( ...args ) =>\n\t\tresolvers.getEntityRecords( kind, name, ...args );\n\tresult[ pluralMethodName ].shouldInvalidate = ( action, ...args ) =>\n\t\tresolvers.getEntityRecords.shouldInvalidate(\n\t\t\taction,\n\t\t\tkind,\n\t\t\tname,\n\t\t\t...args\n\t\t);\n\treturn result;\n}, {} );\n\nconst entityActions = defaultEntities.reduce( ( result, entity ) => {\n\tconst { kind, name } = entity;\n\tresult[ getMethodName( kind, name, 'save' ) ] = ( key ) =>\n\t\tactions.saveEntityRecord( kind, name, key );\n\tresult[ getMethodName( kind, name, 'delete' ) ] = ( key, query ) =>\n\t\tactions.deleteEntityRecord( kind, name, key, query );\n\treturn result;\n}, {} );\n\nconst storeConfig = () => ( {\n\treducer,\n\tactions: { ...actions, ...entityActions, ...createLocksActions() },\n\tselectors: { ...selectors, ...entitySelectors },\n\tresolvers: { ...resolvers, ...entityResolvers },\n} );\n\n/**\n * Store definition for the code data namespace.\n *\n * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/data/README.md#createReduxStore\n *\n * @type {Object}\n */\nexport const store = createReduxStore( STORE_NAME, storeConfig() );\n\nregister( store );\n\nexport { default as EntityProvider } from './entity-provider';\nexport { default as __experimentalUseEntityRecord } from './hooks/use-entity-record';\nexport { default as __experimentalUseEntityRecords } from './hooks/use-entity-records';\nexport * from './entity-provider';\nexport * from './fetch';\nexport * from './types';\n"]}
|
package/build/resolvers.js
CHANGED
|
@@ -334,11 +334,7 @@ const canUser = (action, resource, id) => async _ref7 => {
|
|
|
334
334
|
try {
|
|
335
335
|
response = await (0, _apiFetch.default)({
|
|
336
336
|
path,
|
|
337
|
-
|
|
338
|
-
// a bug in the REST API which causes the Allow header to not be sent on
|
|
339
|
-
// OPTIONS requests to /posts/:id routes.
|
|
340
|
-
// https://core.trac.wordpress.org/ticket/45753
|
|
341
|
-
method: id ? 'GET' : 'OPTIONS',
|
|
337
|
+
method: 'OPTIONS',
|
|
342
338
|
parse: false
|
|
343
339
|
});
|
|
344
340
|
} catch (error) {
|
|
@@ -347,18 +343,7 @@ const canUser = (action, resource, id) => async _ref7 => {
|
|
|
347
343
|
return;
|
|
348
344
|
}
|
|
349
345
|
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
if ((0, _lodash.hasIn)(response, ['headers', 'get'])) {
|
|
353
|
-
// If the request is fetched using the fetch api, the header can be
|
|
354
|
-
// retrieved using the 'get' method.
|
|
355
|
-
allowHeader = response.headers.get('allow');
|
|
356
|
-
} else {
|
|
357
|
-
// If the request was preloaded server-side and is returned by the
|
|
358
|
-
// preloading middleware, the header will be a simple property.
|
|
359
|
-
allowHeader = (0, _lodash.get)(response, ['headers', 'Allow'], '');
|
|
360
|
-
}
|
|
361
|
-
|
|
346
|
+
const allowHeader = response.headers.get('allow');
|
|
362
347
|
const key = (0, _lodash.compact)([action, resource, id]).join('/');
|
|
363
348
|
const isAllowed = (0, _lodash.includes)(allowHeader, method);
|
|
364
349
|
dispatch.receiveUserPermission(key, isAllowed);
|
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;;AA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3G,IAAAA,IAAI,EAAG,+BAA+B0G,YAAY,CAACE,UAAY;AADtB,GAAV,CAAhC;;AAGA7G,EAAAA,QAAQ,CAAC8G,0CAAT,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, hasIn, 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\t// Ideally this would always be an OPTIONS request, but unfortunately there's\n\t\t\t// a bug in the REST API which causes the Allow header to not be sent on\n\t\t\t// OPTIONS requests to /posts/:id routes.\n\t\t\t// https://core.trac.wordpress.org/ticket/45753\n\t\t\tmethod: id ? 'GET' : '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\tlet allowHeader;\n\tif ( hasIn( response, [ 'headers', 'get' ] ) ) {\n\t\t// If the request is fetched using the fetch api, the header can be\n\t\t// retrieved using the 'get' method.\n\t\tallowHeader = response.headers.get( 'allow' );\n\t} else {\n\t\t// If the request was preloaded server-side and is returned by the\n\t\t// preloading middleware, the header will be a simple property.\n\t\tallowHeader = get( response, [ 'headers', 'Allow' ], '' );\n\t}\n\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","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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E,UAAY;AADtB,GAAV,CAAhC;;AAGA7G,EAAAA,QAAQ,CAAC8G,0CAAT,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\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"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","sourcesContent":[]}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.BaseEntityTypes = void 0;
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* This module exists solely to make the BaseEntityTypes namespace extensible
|
|
10
|
+
* with declaration merging:
|
|
11
|
+
*
|
|
12
|
+
* ```ts
|
|
13
|
+
* declare module './base-entity-types' {
|
|
14
|
+
* export namespace BaseEntityTypes {
|
|
15
|
+
* export interface Comment< C extends Context > {
|
|
16
|
+
* id: number;
|
|
17
|
+
* // ...
|
|
18
|
+
* }
|
|
19
|
+
* }
|
|
20
|
+
* }
|
|
21
|
+
* ```
|
|
22
|
+
*
|
|
23
|
+
* The huge upside is that consumers of @wordpress/core-data may extend the
|
|
24
|
+
* exported data types using interface merging as follows:
|
|
25
|
+
*
|
|
26
|
+
* ```ts
|
|
27
|
+
* import type { Context } from '@wordpress/core-data';
|
|
28
|
+
* declare module '@wordpress/core-data' {
|
|
29
|
+
* export namespace BaseEntityTypes {
|
|
30
|
+
* export interface Comment< C extends Context > {
|
|
31
|
+
* numberOfViews: number;
|
|
32
|
+
* }
|
|
33
|
+
* }
|
|
34
|
+
* }
|
|
35
|
+
*
|
|
36
|
+
* import type { Comment } from '@wordpress/core-data';
|
|
37
|
+
* const c : Comment< 'view' > = ...;
|
|
38
|
+
*
|
|
39
|
+
* // c.numberOfViews is a number
|
|
40
|
+
* // c.id is still present
|
|
41
|
+
* ```
|
|
42
|
+
*/
|
|
43
|
+
let BaseEntityTypes;
|
|
44
|
+
exports.BaseEntityTypes = BaseEntityTypes;
|
|
45
|
+
|
|
46
|
+
(function (_BaseEntityTypes) {})(BaseEntityTypes || (exports.BaseEntityTypes = BaseEntityTypes = {}));
|
|
47
|
+
//# sourceMappingURL=base-entity-types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["@wordpress/core-data/src/types/base-entity-types.ts"],"names":["BaseEntityTypes"],"mappings":";;;;;;;AAAA;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;AACA;AACA;;;;iCACiBA,e,+BAAAA,e","sourcesContent":["/**\n * This module exists solely to make the BaseEntityTypes namespace extensible\n * with declaration merging:\n *\n * ```ts\n * declare module './base-entity-types' {\n * export namespace BaseEntityTypes {\n * \t\t export interface Comment< C extends Context > {\n * \t\t id: number;\n * \t\t // ...\n * \t }\n * \t }\n * }\n * ```\n *\n * The huge upside is that consumers of @wordpress/core-data may extend the\n * exported data types using interface merging as follows:\n *\n * ```ts\n * import type { Context } from '@wordpress/core-data';\n * declare module '@wordpress/core-data' {\n * export namespace BaseEntityTypes {\n * export interface Comment< C extends Context > {\n * numberOfViews: number;\n * }\n * }\n * }\n *\n * import type { Comment } from '@wordpress/core-data';\n * const c : Comment< 'view' > = ...;\n *\n * // c.numberOfViews is a number\n * // c.id is still present\n * ```\n */\nexport namespace BaseEntityTypes {}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","sourcesContent":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","sourcesContent":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","sourcesContent":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","sourcesContent":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","sourcesContent":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","sourcesContent":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","sourcesContent":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","sourcesContent":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","sourcesContent":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","sourcesContent":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","sourcesContent":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","sourcesContent":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","sourcesContent":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","sourcesContent":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","sourcesContent":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","sourcesContent":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","sourcesContent":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","sourcesContent":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","sourcesContent":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","sourcesContent":[]}
|
package/build-module/actions.js
CHANGED
|
@@ -472,7 +472,7 @@ export const saveEntityRecord = function (kind, name, record) {
|
|
|
472
472
|
// so the client just sends and receives objects.
|
|
473
473
|
const currentUser = select.getCurrentUser();
|
|
474
474
|
const currentUserId = currentUser ? currentUser.id : undefined;
|
|
475
|
-
const autosavePost = resolveSelect.getAutosave(persistedRecord.type, persistedRecord.id, currentUserId); // Autosaves need all expected fields to be present.
|
|
475
|
+
const autosavePost = await resolveSelect.getAutosave(persistedRecord.type, persistedRecord.id, currentUserId); // Autosaves need all expected fields to be present.
|
|
476
476
|
// So we fallback to the previous autosave and then
|
|
477
477
|
// to the actual persisted entity if the edits don't
|
|
478
478
|
// have a value.
|