@wordpress/core-data 7.34.0 → 7.34.1-next.2f1c7c01b.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/build/actions.js +12 -10
- package/build/actions.js.map +1 -1
- package/build/batch/create-batch.js +4 -2
- package/build/batch/create-batch.js.map +1 -1
- package/build/batch/default-processor.js +3 -1
- package/build/batch/default-processor.js.map +1 -1
- package/build/batch/index.js +2 -0
- package/build/batch/index.js.map +1 -1
- package/build/dynamic-entities.js +4 -2
- package/build/dynamic-entities.js.map +1 -1
- package/build/entities.js +10 -8
- package/build/entities.js.map +1 -1
- package/build/entity-context.js +3 -1
- package/build/entity-context.js.map +1 -1
- package/build/entity-provider.js +3 -1
- package/build/entity-provider.js.map +1 -1
- package/build/entity-types/attachment.js +2 -0
- package/build/entity-types/attachment.js.map +1 -1
- package/build/entity-types/base-entity-records.js +2 -0
- package/build/entity-types/base-entity-records.js.map +1 -1
- package/build/entity-types/base.js +2 -0
- package/build/entity-types/base.js.map +1 -1
- package/build/entity-types/comment.js +2 -0
- package/build/entity-types/comment.js.map +1 -1
- package/build/entity-types/global-styles-revision.js +2 -0
- package/build/entity-types/global-styles-revision.js.map +1 -1
- package/build/entity-types/helpers.js +2 -0
- package/build/entity-types/helpers.js.map +1 -1
- package/build/entity-types/index.js +2 -0
- package/build/entity-types/index.js.map +1 -1
- package/build/entity-types/menu-location.js +2 -0
- package/build/entity-types/menu-location.js.map +1 -1
- package/build/entity-types/nav-menu-item.js +2 -0
- package/build/entity-types/nav-menu-item.js.map +1 -1
- package/build/entity-types/nav-menu.js +2 -0
- package/build/entity-types/nav-menu.js.map +1 -1
- package/build/entity-types/page.js +2 -0
- package/build/entity-types/page.js.map +1 -1
- package/build/entity-types/plugin.js +2 -0
- package/build/entity-types/plugin.js.map +1 -1
- package/build/entity-types/post-revision.js +2 -0
- package/build/entity-types/post-revision.js.map +1 -1
- package/build/entity-types/post-status.js +2 -0
- package/build/entity-types/post-status.js.map +1 -1
- package/build/entity-types/post.js +2 -0
- package/build/entity-types/post.js.map +1 -1
- package/build/entity-types/settings.js +2 -0
- package/build/entity-types/settings.js.map +1 -1
- package/build/entity-types/sidebar.js +2 -0
- package/build/entity-types/sidebar.js.map +1 -1
- package/build/entity-types/taxonomy.js +2 -0
- package/build/entity-types/taxonomy.js.map +1 -1
- package/build/entity-types/term.js +2 -0
- package/build/entity-types/term.js.map +1 -1
- package/build/entity-types/theme.js +2 -0
- package/build/entity-types/theme.js.map +1 -1
- package/build/entity-types/type.js +2 -0
- package/build/entity-types/type.js.map +1 -1
- package/build/entity-types/user.js +2 -0
- package/build/entity-types/user.js.map +1 -1
- package/build/entity-types/widget-type.js +2 -0
- package/build/entity-types/widget-type.js.map +1 -1
- package/build/entity-types/widget.js +2 -0
- package/build/entity-types/widget.js.map +1 -1
- package/build/entity-types/wp-template-part.js +2 -0
- package/build/entity-types/wp-template-part.js.map +1 -1
- package/build/entity-types/wp-template.js +2 -0
- package/build/entity-types/wp-template.js.map +1 -1
- package/build/fetch/__experimental-fetch-link-suggestions.js +2 -0
- package/build/fetch/__experimental-fetch-link-suggestions.js.map +1 -1
- package/build/fetch/__experimental-fetch-url-data.js +4 -2
- package/build/fetch/__experimental-fetch-url-data.js.map +1 -1
- package/build/fetch/index.js +2 -0
- package/build/fetch/index.js.map +1 -1
- package/build/footnotes/get-footnotes-order.js +3 -1
- package/build/footnotes/get-footnotes-order.js.map +1 -1
- package/build/footnotes/get-rich-text-values-cached.js +4 -2
- package/build/footnotes/get-rich-text-values-cached.js.map +1 -1
- package/build/footnotes/index.js +3 -1
- package/build/footnotes/index.js.map +1 -1
- package/build/hooks/constants.js +2 -0
- package/build/hooks/constants.js.map +1 -1
- package/build/hooks/index.js +2 -0
- package/build/hooks/index.js.map +1 -1
- package/build/hooks/memoize.js +2 -0
- package/build/hooks/memoize.js.map +1 -1
- package/build/hooks/use-entity-block-editor.js +4 -2
- package/build/hooks/use-entity-block-editor.js.map +1 -1
- package/build/hooks/use-entity-id.js +2 -0
- package/build/hooks/use-entity-id.js.map +1 -1
- package/build/hooks/use-entity-prop.js +2 -0
- package/build/hooks/use-entity-prop.js.map +1 -1
- package/build/hooks/use-entity-record.js +3 -1
- package/build/hooks/use-entity-record.js.map +1 -1
- package/build/hooks/use-entity-records.js +3 -1
- package/build/hooks/use-entity-records.js.map +1 -1
- package/build/hooks/use-query-select.js +4 -2
- package/build/hooks/use-query-select.js.map +1 -1
- package/build/hooks/use-resource-permissions.js +2 -0
- package/build/hooks/use-resource-permissions.js.map +1 -1
- package/build/index.js +8 -6
- package/build/index.js.map +1 -1
- package/build/lock-unlock.js +3 -1
- package/build/lock-unlock.js.map +1 -1
- package/build/locks/actions.js +2 -0
- package/build/locks/actions.js.map +1 -1
- package/build/locks/engine.js +2 -0
- package/build/locks/engine.js.map +1 -1
- package/build/locks/reducer.js +3 -1
- package/build/locks/reducer.js.map +1 -1
- package/build/locks/selectors.js +2 -0
- package/build/locks/selectors.js.map +1 -1
- package/build/locks/utils.js +2 -0
- package/build/locks/utils.js.map +1 -1
- package/build/name.js +3 -1
- package/build/name.js.map +1 -1
- package/build/private-actions.js +3 -1
- package/build/private-actions.js.map +1 -1
- package/build/private-apis.js +3 -1
- package/build/private-apis.js.map +1 -1
- package/build/private-selectors.js +7 -5
- package/build/private-selectors.js.map +1 -1
- package/build/queried-data/actions.js +2 -0
- package/build/queried-data/actions.js.map +1 -1
- package/build/queried-data/get-query-parts.js +2 -0
- package/build/queried-data/get-query-parts.js.map +1 -1
- package/build/queried-data/index.js +2 -0
- package/build/queried-data/index.js.map +1 -1
- package/build/queried-data/reducer.js +4 -2
- package/build/queried-data/reducer.js.map +1 -1
- package/build/queried-data/selectors.js +4 -2
- package/build/queried-data/selectors.js.map +1 -1
- package/build/reducer.js +4 -2
- package/build/reducer.js.map +1 -1
- package/build/resolvers.js +30 -28
- package/build/resolvers.js.map +1 -1
- package/build/selectors.js +18 -16
- package/build/selectors.js.map +1 -1
- package/build/sync.js +3 -1
- package/build/sync.js.map +1 -1
- package/build/types.js +2 -0
- package/build/types.js.map +1 -1
- package/build/utils/conservative-map-item.js +2 -0
- package/build/utils/conservative-map-item.js.map +1 -1
- package/build/utils/crdt-blocks.js +4 -2
- package/build/utils/crdt-blocks.js.map +1 -1
- package/build/utils/crdt.js +5 -3
- package/build/utils/crdt.js.map +1 -1
- package/build/utils/forward-resolver.js +3 -1
- package/build/utils/forward-resolver.js.map +1 -1
- package/build/utils/get-nested-value.js +2 -0
- package/build/utils/get-nested-value.js.map +1 -1
- package/build/utils/get-normalized-comma-separable.js +2 -0
- package/build/utils/get-normalized-comma-separable.js.map +1 -1
- package/build/utils/if-matching-action.js +3 -1
- package/build/utils/if-matching-action.js.map +1 -1
- package/build/utils/index.js +2 -0
- package/build/utils/index.js.map +1 -1
- package/build/utils/is-numeric-id.js +2 -0
- package/build/utils/is-numeric-id.js.map +1 -1
- package/build/utils/is-raw-attribute.js +2 -0
- package/build/utils/is-raw-attribute.js.map +1 -1
- package/build/utils/log-entity-deprecation.js +3 -1
- package/build/utils/log-entity-deprecation.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/receive-intermediate-results.js +3 -1
- package/build/utils/receive-intermediate-results.js.map +1 -1
- package/build/utils/replace-action.js +3 -1
- package/build/utils/replace-action.js.map +1 -1
- package/build/utils/set-nested-value.js +2 -0
- package/build/utils/set-nested-value.js.map +1 -1
- package/build/utils/user-permissions.js +3 -1
- package/build/utils/user-permissions.js.map +1 -1
- package/build/utils/with-weak-map-cache.js +2 -0
- package/build/utils/with-weak-map-cache.js.map +1 -1
- package/build-module/actions.js +11 -10
- package/build-module/actions.js.map +1 -1
- package/build-module/batch/create-batch.js +3 -2
- package/build-module/batch/create-batch.js.map +1 -1
- package/build-module/batch/default-processor.js +2 -1
- package/build-module/batch/default-processor.js.map +1 -1
- package/build-module/batch/index.js +1 -0
- package/build-module/batch/index.js.map +1 -1
- package/build-module/dynamic-entities.js +3 -2
- package/build-module/dynamic-entities.js.map +1 -1
- package/build-module/entities.js +9 -8
- package/build-module/entities.js.map +1 -1
- package/build-module/entity-context.js +2 -1
- package/build-module/entity-context.js.map +1 -1
- package/build-module/entity-provider.js +2 -1
- package/build-module/entity-provider.js.map +1 -1
- package/build-module/fetch/__experimental-fetch-link-suggestions.js +1 -0
- package/build-module/fetch/__experimental-fetch-link-suggestions.js.map +1 -1
- package/build-module/fetch/__experimental-fetch-url-data.js +3 -2
- package/build-module/fetch/__experimental-fetch-url-data.js.map +1 -1
- package/build-module/fetch/index.js +1 -0
- package/build-module/fetch/index.js.map +1 -1
- package/build-module/footnotes/get-footnotes-order.js +2 -1
- package/build-module/footnotes/get-footnotes-order.js.map +1 -1
- package/build-module/footnotes/get-rich-text-values-cached.js +3 -2
- package/build-module/footnotes/get-rich-text-values-cached.js.map +1 -1
- package/build-module/footnotes/index.js +2 -1
- package/build-module/footnotes/index.js.map +1 -1
- package/build-module/hooks/constants.js +1 -0
- package/build-module/hooks/constants.js.map +1 -1
- package/build-module/hooks/index.js +1 -0
- package/build-module/hooks/index.js.map +1 -1
- package/build-module/hooks/memoize.js +1 -0
- package/build-module/hooks/memoize.js.map +1 -1
- package/build-module/hooks/use-entity-block-editor.js +3 -2
- package/build-module/hooks/use-entity-block-editor.js.map +1 -1
- package/build-module/hooks/use-entity-id.js +1 -0
- package/build-module/hooks/use-entity-id.js.map +1 -1
- package/build-module/hooks/use-entity-prop.js +1 -0
- package/build-module/hooks/use-entity-prop.js.map +1 -1
- package/build-module/hooks/use-entity-record.js +2 -1
- package/build-module/hooks/use-entity-record.js.map +1 -1
- package/build-module/hooks/use-entity-records.js +2 -1
- package/build-module/hooks/use-entity-records.js.map +1 -1
- package/build-module/hooks/use-query-select.js +3 -2
- package/build-module/hooks/use-query-select.js.map +1 -1
- package/build-module/hooks/use-resource-permissions.js +1 -0
- package/build-module/hooks/use-resource-permissions.js.map +1 -1
- package/build-module/index.js +13 -12
- package/build-module/index.js.map +1 -1
- package/build-module/lock-unlock.js +2 -1
- package/build-module/lock-unlock.js.map +1 -1
- package/build-module/locks/actions.js +1 -0
- package/build-module/locks/actions.js.map +1 -1
- package/build-module/locks/engine.js +1 -0
- package/build-module/locks/engine.js.map +1 -1
- package/build-module/locks/reducer.js +2 -1
- package/build-module/locks/reducer.js.map +1 -1
- package/build-module/locks/selectors.js +1 -0
- package/build-module/locks/selectors.js.map +1 -1
- package/build-module/locks/utils.js +1 -0
- package/build-module/locks/utils.js.map +1 -1
- package/build-module/name.js +2 -1
- package/build-module/name.js.map +1 -1
- package/build-module/private-actions.js +2 -1
- package/build-module/private-actions.js.map +1 -1
- package/build-module/private-apis.js +2 -1
- package/build-module/private-apis.js.map +1 -1
- package/build-module/private-selectors.js +6 -5
- package/build-module/private-selectors.js.map +1 -1
- package/build-module/queried-data/actions.js +1 -0
- package/build-module/queried-data/actions.js.map +1 -1
- package/build-module/queried-data/get-query-parts.js +1 -0
- package/build-module/queried-data/get-query-parts.js.map +1 -1
- package/build-module/queried-data/index.js +1 -0
- package/build-module/queried-data/index.js.map +1 -1
- package/build-module/queried-data/reducer.js +3 -2
- package/build-module/queried-data/reducer.js.map +1 -1
- package/build-module/queried-data/selectors.js +3 -2
- package/build-module/queried-data/selectors.js.map +1 -1
- package/build-module/reducer.js +3 -2
- package/build-module/reducer.js.map +1 -1
- package/build-module/resolvers.js +29 -28
- package/build-module/resolvers.js.map +1 -1
- package/build-module/selectors.js +17 -16
- package/build-module/selectors.js.map +1 -1
- package/build-module/sync.js +2 -1
- package/build-module/sync.js.map +1 -1
- package/build-module/utils/conservative-map-item.js +1 -0
- package/build-module/utils/conservative-map-item.js.map +1 -1
- package/build-module/utils/crdt-blocks.js +3 -2
- package/build-module/utils/crdt-blocks.js.map +1 -1
- package/build-module/utils/crdt.js +4 -3
- package/build-module/utils/crdt.js.map +1 -1
- package/build-module/utils/forward-resolver.js +2 -1
- package/build-module/utils/forward-resolver.js.map +1 -1
- package/build-module/utils/get-nested-value.js +1 -0
- package/build-module/utils/get-nested-value.js.map +1 -1
- package/build-module/utils/get-normalized-comma-separable.js +1 -0
- package/build-module/utils/get-normalized-comma-separable.js.map +1 -1
- package/build-module/utils/if-matching-action.js +2 -1
- package/build-module/utils/if-matching-action.js.map +1 -1
- package/build-module/utils/index.js +1 -0
- package/build-module/utils/index.js.map +1 -1
- package/build-module/utils/is-numeric-id.js +1 -0
- package/build-module/utils/is-numeric-id.js.map +1 -1
- package/build-module/utils/is-raw-attribute.js +1 -0
- package/build-module/utils/is-raw-attribute.js.map +1 -1
- package/build-module/utils/log-entity-deprecation.js +2 -1
- package/build-module/utils/log-entity-deprecation.js.map +1 -1
- package/build-module/utils/on-sub-key.js +2 -1
- package/build-module/utils/on-sub-key.js.map +1 -1
- package/build-module/utils/receive-intermediate-results.js +2 -1
- package/build-module/utils/receive-intermediate-results.js.map +1 -1
- package/build-module/utils/replace-action.js +2 -1
- package/build-module/utils/replace-action.js.map +1 -1
- package/build-module/utils/set-nested-value.js +1 -0
- package/build-module/utils/set-nested-value.js.map +1 -1
- package/build-module/utils/user-permissions.js +2 -1
- package/build-module/utils/user-permissions.js.map +1 -1
- package/build-module/utils/with-weak-map-cache.js +1 -0
- package/build-module/utils/with-weak-map-cache.js.map +1 -1
- package/package.json +18 -18
- package/src/test/resolvers.js +78 -0
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/utils/index.js"],
|
|
4
4
|
"sourcesContent": ["export { default as conservativeMapItem } from './conservative-map-item';\nexport { default as getNormalizedCommaSeparable } from './get-normalized-comma-separable';\nexport { default as ifMatchingAction } from './if-matching-action';\nexport { default as forwardResolver } from './forward-resolver';\nexport { default as onSubKey } from './on-sub-key';\nexport { default as replaceAction } from './replace-action';\nexport { default as withWeakMapCache } from './with-weak-map-cache';\nexport { default as isRawAttribute } from './is-raw-attribute';\nexport { default as setNestedValue } from './set-nested-value';\nexport { default as getNestedValue } from './get-nested-value';\nexport { default as isNumericID } from './is-numeric-id';\nexport {\n\tgetUserPermissionCacheKey,\n\tgetUserPermissionsFromAllowHeader,\n\tALLOWED_RESOURCE_ACTIONS,\n} from './user-permissions';\nexport { RECEIVE_INTERMEDIATE_RESULTS } from './receive-intermediate-results';\n"],
|
|
5
|
-
"mappings": "AAAA,SAAoB,WAAXA,gBAAsC;AAC/C,SAAoB,WAAXA,gBAA8C;AACvD,SAAoB,WAAXA,gBAAmC;AAC5C,SAAoB,WAAXA,gBAAkC;AAC3C,SAAoB,WAAXA,gBAA2B;AACpC,SAAoB,WAAXA,gBAAgC;AACzC,SAAoB,WAAXA,gBAAmC;AAC5C,SAAoB,WAAXA,gBAAiC;AAC1C,SAAoB,WAAXA,iBAAiC;AAC1C,SAAoB,WAAXA,iBAAiC;AAC1C,SAAoB,WAAXA,iBAA8B;AACvC;AAAA,EACC;AAAA,EACA;AAAA,EACA;AAAA,OACM;AACP,SAAS,oCAAoC;",
|
|
5
|
+
"mappings": ";AAAA,SAAoB,WAAXA,gBAAsC;AAC/C,SAAoB,WAAXA,gBAA8C;AACvD,SAAoB,WAAXA,gBAAmC;AAC5C,SAAoB,WAAXA,gBAAkC;AAC3C,SAAoB,WAAXA,gBAA2B;AACpC,SAAoB,WAAXA,gBAAgC;AACzC,SAAoB,WAAXA,gBAAmC;AAC5C,SAAoB,WAAXA,gBAAiC;AAC1C,SAAoB,WAAXA,iBAAiC;AAC1C,SAAoB,WAAXA,iBAAiC;AAC1C,SAAoB,WAAXA,iBAA8B;AACvC;AAAA,EACC;AAAA,EACA;AAAA,EACA;AAAA,OACM;AACP,SAAS,oCAAoC;",
|
|
6
6
|
"names": ["default"]
|
|
7
7
|
}
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/utils/is-numeric-id.js"],
|
|
4
4
|
"sourcesContent": ["/**\n * Checks argument to determine if it's a numeric ID.\n * For example, '123' is a numeric ID, but '123abc' is not.\n *\n * @param {any} id the argument to determine if it's a numeric ID.\n * @return {boolean} true if the string is a numeric ID, false otherwise.\n */\nexport default function isNumericID( id ) {\n\treturn /^\\s*\\d+\\s*$/.test( id );\n}\n"],
|
|
5
|
-
"mappings": "AAOe,SAAR,YAA8B,IAAK;AACzC,SAAO,cAAc,KAAM,EAAG;AAC/B;",
|
|
5
|
+
"mappings": ";AAOe,SAAR,YAA8B,IAAK;AACzC,SAAO,cAAc,KAAM,EAAG;AAC/B;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/utils/is-raw-attribute.js"],
|
|
4
4
|
"sourcesContent": ["/**\n * Checks whether the attribute is a \"raw\" attribute or not.\n *\n * @param {Object} entity Entity record.\n * @param {string} attribute Attribute name.\n *\n * @return {boolean} Is the attribute raw\n */\nexport default function isRawAttribute( entity, attribute ) {\n\treturn ( entity.rawAttributes || [] ).includes( attribute );\n}\n"],
|
|
5
|
-
"mappings": "AAQe,SAAR,eAAiC,QAAQ,WAAY;AAC3D,UAAS,OAAO,iBAAiB,CAAC,GAAI,SAAU,SAAU;AAC3D;",
|
|
5
|
+
"mappings": ";AAQe,SAAR,eAAiC,QAAQ,WAAY;AAC3D,UAAS,OAAO,iBAAiB,CAAC,GAAI,SAAU,SAAU;AAC3D;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
+
// packages/core-data/src/utils/log-entity-deprecation.ts
|
|
1
2
|
import deprecated from "@wordpress/deprecated";
|
|
2
3
|
import { deprecatedEntities } from "../entities";
|
|
3
|
-
|
|
4
|
+
var loggedAlready = false;
|
|
4
5
|
function logEntityDeprecation(kind, name, functionName, {
|
|
5
6
|
alternativeFunctionName,
|
|
6
7
|
isShorthandSelector = false
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/utils/log-entity-deprecation.ts"],
|
|
4
4
|
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport deprecated from '@wordpress/deprecated';\n\n/**\n * Internal dependencies\n */\nimport { deprecatedEntities } from '../entities';\n\nlet loggedAlready = false;\n\n/**\n * Logs a deprecation warning for an entity, if it's deprecated.\n *\n * @param kind The kind of the entity.\n * @param name The name of the entity.\n * @param functionName The name of the function that was called with a deprecated entity.\n * @param options The options for the deprecation warning.\n * @param options.alternativeFunctionName The name of the alternative function that should be used instead.\n * @param options.isShorthandSelector Whether the function is a shorthand selector.\n */\nexport default function logEntityDeprecation(\n\tkind: string,\n\tname: string,\n\tfunctionName: string,\n\t{\n\t\talternativeFunctionName,\n\t\tisShorthandSelector = false,\n\t}: {\n\t\talternativeFunctionName?: string;\n\t\tisShorthandSelector?: boolean;\n\t} = {}\n) {\n\tconst deprecation = deprecatedEntities[ kind ]?.[ name ];\n\tif ( ! deprecation ) {\n\t\treturn;\n\t}\n\n\tif ( ! loggedAlready ) {\n\t\tconst { alternative } = deprecation;\n\n\t\tconst message = isShorthandSelector\n\t\t\t? `'${ functionName }'`\n\t\t\t: `The '${ kind }', '${ name }' entity (used via '${ functionName }')`;\n\n\t\tlet alternativeMessage = `the '${ alternative.kind }', '${ alternative.name }' entity`;\n\t\tif ( alternativeFunctionName ) {\n\t\t\talternativeMessage += ` via the '${ alternativeFunctionName }' function`;\n\t\t}\n\n\t\tdeprecated( message, {\n\t\t\t...deprecation,\n\t\t\talternative: alternativeMessage,\n\t\t} );\n\t}\n\n\t// Only log an entity deprecation once per call stack,\n\t// else there's spurious logging when selections or actions call through to other selectors or actions.\n\t// Note: this won't prevent the deprecation warning being logged if a selector or action makes an async call\n\t// to another selector or action, but this is probably the best we can do.\n\tloggedAlready = true;\n\t// At the end of the call stack, reset the flag.\n\tsetTimeout( () => {\n\t\tloggedAlready = false;\n\t}, 0 );\n}\n"],
|
|
5
|
-
"mappings": "AAGA,OAAO,gBAAgB;AAKvB,SAAS,0BAA0B;AAEnC,IAAI,gBAAgB;AAYL,SAAR,qBACN,MACA,MACA,cACA;AAAA,EACC;AAAA,EACA,sBAAsB;AACvB,IAGI,CAAC,GACJ;AACD,QAAM,cAAc,mBAAoB,IAAK,IAAK,IAAK;AACvD,MAAK,CAAE,aAAc;AACpB;AAAA,EACD;AAEA,MAAK,CAAE,eAAgB;AACtB,UAAM,EAAE,YAAY,IAAI;AAExB,UAAM,UAAU,sBACb,IAAK,YAAa,MAClB,QAAS,IAAK,OAAQ,IAAK,uBAAwB,YAAa;AAEnE,QAAI,qBAAqB,QAAS,YAAY,IAAK,OAAQ,YAAY,IAAK;AAC5E,QAAK,yBAA0B;AAC9B,4BAAsB,aAAc,uBAAwB;AAAA,IAC7D;AAEA,eAAY,SAAS;AAAA,MACpB,GAAG;AAAA,MACH,aAAa;AAAA,IACd,CAAE;AAAA,EACH;AAMA,kBAAgB;AAEhB,aAAY,MAAM;AACjB,oBAAgB;AAAA,EACjB,GAAG,CAAE;AACN;",
|
|
5
|
+
"mappings": ";AAGA,OAAO,gBAAgB;AAKvB,SAAS,0BAA0B;AAEnC,IAAI,gBAAgB;AAYL,SAAR,qBACN,MACA,MACA,cACA;AAAA,EACC;AAAA,EACA,sBAAsB;AACvB,IAGI,CAAC,GACJ;AACD,QAAM,cAAc,mBAAoB,IAAK,IAAK,IAAK;AACvD,MAAK,CAAE,aAAc;AACpB;AAAA,EACD;AAEA,MAAK,CAAE,eAAgB;AACtB,UAAM,EAAE,YAAY,IAAI;AAExB,UAAM,UAAU,sBACb,IAAK,YAAa,MAClB,QAAS,IAAK,OAAQ,IAAK,uBAAwB,YAAa;AAEnE,QAAI,qBAAqB,QAAS,YAAY,IAAK,OAAQ,YAAY,IAAK;AAC5E,QAAK,yBAA0B;AAC9B,4BAAsB,aAAc,uBAAwB;AAAA,IAC7D;AAEA,eAAY,SAAS;AAAA,MACpB,GAAG;AAAA,MACH,aAAa;AAAA,IACd,CAAE;AAAA,EACH;AAMA,kBAAgB;AAEhB,aAAY,MAAM;AACjB,oBAAgB;AAAA,EACjB,GAAG,CAAE;AACN;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
|
|
1
|
+
// packages/core-data/src/utils/on-sub-key.js
|
|
2
|
+
var onSubKey = (actionProperty) => (reducer) => (state = {}, action) => {
|
|
2
3
|
const key = action[actionProperty];
|
|
3
4
|
if (key === void 0) {
|
|
4
5
|
return state;
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/utils/on-sub-key.js"],
|
|
4
4
|
"sourcesContent": ["/** @typedef {import('../types').AnyFunction} AnyFunction */\n\n/**\n * Higher-order reducer creator which creates a combined reducer object, keyed\n * by a property on the action object.\n *\n * @param {string} actionProperty Action property by which to key object.\n *\n * @return {AnyFunction} Higher-order reducer.\n */\nexport const onSubKey =\n\t( actionProperty ) =>\n\t( reducer ) =>\n\t( state = {}, action ) => {\n\t\t// Retrieve subkey from action. Do not track if undefined; useful for cases\n\t\t// where reducer is scoped by action shape.\n\t\tconst key = action[ actionProperty ];\n\t\tif ( key === undefined ) {\n\t\t\treturn state;\n\t\t}\n\n\t\t// Avoid updating state if unchanged. Note that this also accounts for a\n\t\t// reducer which returns undefined on a key which is not yet tracked.\n\t\tconst nextKeyState = reducer( state[ key ], action );\n\t\tif ( nextKeyState === state[ key ] ) {\n\t\t\treturn state;\n\t\t}\n\n\t\treturn {\n\t\t\t...state,\n\t\t\t[ key ]: nextKeyState,\n\t\t};\n\t};\n\nexport default onSubKey;\n"],
|
|
5
|
-
"mappings": "AAUO,
|
|
5
|
+
"mappings": ";AAUO,IAAM,WACZ,CAAE,mBACF,CAAE,YACF,CAAE,QAAQ,CAAC,GAAG,WAAY;AAGzB,QAAM,MAAM,OAAQ,cAAe;AACnC,MAAK,QAAQ,QAAY;AACxB,WAAO;AAAA,EACR;AAIA,QAAM,eAAe,QAAS,MAAO,GAAI,GAAG,MAAO;AACnD,MAAK,iBAAiB,MAAO,GAAI,GAAI;AACpC,WAAO;AAAA,EACR;AAEA,SAAO;AAAA,IACN,GAAG;AAAA,IACH,CAAE,GAAI,GAAG;AAAA,EACV;AACD;AAED,IAAO,qBAAQ;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/utils/receive-intermediate-results.js"],
|
|
4
4
|
"sourcesContent": ["export const RECEIVE_INTERMEDIATE_RESULTS = Symbol(\n\t'RECEIVE_INTERMEDIATE_RESULTS'\n);\n"],
|
|
5
|
-
"mappings": "AAAO,
|
|
5
|
+
"mappings": ";AAAO,IAAM,+BAA+B;AAAA,EAC3C;AACD;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
|
|
1
|
+
// packages/core-data/src/utils/replace-action.js
|
|
2
|
+
var replaceAction = (replacer) => (reducer) => (state, action) => {
|
|
2
3
|
return reducer(state, replacer(action));
|
|
3
4
|
};
|
|
4
5
|
var replace_action_default = replaceAction;
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/utils/replace-action.js"],
|
|
4
4
|
"sourcesContent": ["/** @typedef {import('../types').AnyFunction} AnyFunction */\n\n/**\n * Higher-order reducer creator which substitutes the action object before\n * passing to the original reducer.\n *\n * @param {AnyFunction} replacer Function mapping original action to replacement.\n *\n * @return {AnyFunction} Higher-order reducer.\n */\nconst replaceAction = ( replacer ) => ( reducer ) => ( state, action ) => {\n\treturn reducer( state, replacer( action ) );\n};\n\nexport default replaceAction;\n"],
|
|
5
|
-
"mappings": "AAUA,
|
|
5
|
+
"mappings": ";AAUA,IAAM,gBAAgB,CAAE,aAAc,CAAE,YAAa,CAAE,OAAO,WAAY;AACzE,SAAO,QAAS,OAAO,SAAU,MAAO,CAAE;AAC3C;AAEA,IAAO,yBAAQ;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/utils/set-nested-value.js"],
|
|
4
4
|
"sourcesContent": ["/**\n * Sets the value at path of object.\n * If a portion of path doesn\u2019t exist, it\u2019s created.\n * Arrays are created for missing index properties while objects are created\n * for all other missing properties.\n *\n * Path is specified as either:\n * - a string of properties, separated by dots, for example: \"x.y\".\n * - an array of properties, for example `[ 'x', 'y' ]`.\n *\n * This function intentionally mutates the input object.\n *\n * Inspired by _.set().\n *\n * @see https://lodash.com/docs/4.17.15#set\n *\n * @todo Needs to be deduplicated with its copy in `@wordpress/edit-site`.\n *\n * @param {Object} object Object to modify\n * @param {Array|string} path Path of the property to set.\n * @param {*} value Value to set.\n */\nexport default function setNestedValue( object, path, value ) {\n\tif ( ! object || typeof object !== 'object' ) {\n\t\treturn object;\n\t}\n\n\tconst normalizedPath = Array.isArray( path ) ? path : path.split( '.' );\n\n\tnormalizedPath.reduce( ( acc, key, idx ) => {\n\t\tif ( acc[ key ] === undefined ) {\n\t\t\tif ( Number.isInteger( normalizedPath[ idx + 1 ] ) ) {\n\t\t\t\tacc[ key ] = [];\n\t\t\t} else {\n\t\t\t\tacc[ key ] = {};\n\t\t\t}\n\t\t}\n\t\tif ( idx === normalizedPath.length - 1 ) {\n\t\t\tacc[ key ] = value;\n\t\t}\n\t\treturn acc[ key ];\n\t}, object );\n\n\treturn object;\n}\n"],
|
|
5
|
-
"mappings": "AAsBe,SAAR,eAAiC,QAAQ,MAAM,OAAQ;AAC7D,MAAK,CAAE,UAAU,OAAO,WAAW,UAAW;AAC7C,WAAO;AAAA,EACR;AAEA,QAAM,iBAAiB,MAAM,QAAS,IAAK,IAAI,OAAO,KAAK,MAAO,GAAI;AAEtE,iBAAe,OAAQ,CAAE,KAAK,KAAK,QAAS;AAC3C,QAAK,IAAK,GAAI,MAAM,QAAY;AAC/B,UAAK,OAAO,UAAW,eAAgB,MAAM,CAAE,CAAE,GAAI;AACpD,YAAK,GAAI,IAAI,CAAC;AAAA,MACf,OAAO;AACN,YAAK,GAAI,IAAI,CAAC;AAAA,MACf;AAAA,IACD;AACA,QAAK,QAAQ,eAAe,SAAS,GAAI;AACxC,UAAK,GAAI,IAAI;AAAA,IACd;AACA,WAAO,IAAK,GAAI;AAAA,EACjB,GAAG,MAAO;AAEV,SAAO;AACR;",
|
|
5
|
+
"mappings": ";AAsBe,SAAR,eAAiC,QAAQ,MAAM,OAAQ;AAC7D,MAAK,CAAE,UAAU,OAAO,WAAW,UAAW;AAC7C,WAAO;AAAA,EACR;AAEA,QAAM,iBAAiB,MAAM,QAAS,IAAK,IAAI,OAAO,KAAK,MAAO,GAAI;AAEtE,iBAAe,OAAQ,CAAE,KAAK,KAAK,QAAS;AAC3C,QAAK,IAAK,GAAI,MAAM,QAAY;AAC/B,UAAK,OAAO,UAAW,eAAgB,MAAM,CAAE,CAAE,GAAI;AACpD,YAAK,GAAI,IAAI,CAAC;AAAA,MACf,OAAO;AACN,YAAK,GAAI,IAAI,CAAC;AAAA,MACf;AAAA,IACD;AACA,QAAK,QAAQ,eAAe,SAAS,GAAI;AACxC,UAAK,GAAI,IAAI;AAAA,IACd;AACA,WAAO,IAAK,GAAI;AAAA,EACjB,GAAG,MAAO;AAEV,SAAO;AACR;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/utils/user-permissions.js"],
|
|
4
4
|
"sourcesContent": ["export const ALLOWED_RESOURCE_ACTIONS = [\n\t'create',\n\t'read',\n\t'update',\n\t'delete',\n];\n\nexport function getUserPermissionsFromAllowHeader( allowedMethods ) {\n\tconst permissions = {};\n\tif ( ! allowedMethods ) {\n\t\treturn permissions;\n\t}\n\n\tconst methods = {\n\t\tcreate: 'POST',\n\t\tread: 'GET',\n\t\tupdate: 'PUT',\n\t\tdelete: 'DELETE',\n\t};\n\tfor ( const [ actionName, methodName ] of Object.entries( methods ) ) {\n\t\tpermissions[ actionName ] = allowedMethods.includes( methodName );\n\t}\n\n\treturn permissions;\n}\n\nexport function getUserPermissionCacheKey( action, resource, id ) {\n\tconst key = (\n\t\ttypeof resource === 'object'\n\t\t\t? [ action, resource.kind, resource.name, resource.id ]\n\t\t\t: [ action, resource, id ]\n\t)\n\t\t.filter( Boolean )\n\t\t.join( '/' );\n\n\treturn key;\n}\n"],
|
|
5
|
-
"mappings": "AAAO,
|
|
5
|
+
"mappings": ";AAAO,IAAM,2BAA2B;AAAA,EACvC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACD;AAEO,SAAS,kCAAmC,gBAAiB;AACnE,QAAM,cAAc,CAAC;AACrB,MAAK,CAAE,gBAAiB;AACvB,WAAO;AAAA,EACR;AAEA,QAAM,UAAU;AAAA,IACf,QAAQ;AAAA,IACR,MAAM;AAAA,IACN,QAAQ;AAAA,IACR,QAAQ;AAAA,EACT;AACA,aAAY,CAAE,YAAY,UAAW,KAAK,OAAO,QAAS,OAAQ,GAAI;AACrE,gBAAa,UAAW,IAAI,eAAe,SAAU,UAAW;AAAA,EACjE;AAEA,SAAO;AACR;AAEO,SAAS,0BAA2B,QAAQ,UAAU,IAAK;AACjE,QAAM,OACL,OAAO,aAAa,WACjB,CAAE,QAAQ,SAAS,MAAM,SAAS,MAAM,SAAS,EAAG,IACpD,CAAE,QAAQ,UAAU,EAAG,GAEzB,OAAQ,OAAQ,EAChB,KAAM,GAAI;AAEZ,SAAO;AACR;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/utils/with-weak-map-cache.js"],
|
|
4
4
|
"sourcesContent": ["/**\n * Given a function, returns an enhanced function which caches the result and\n * tracks in WeakMap. The result is only cached if the original function is\n * passed a valid object-like argument (requirement for WeakMap key).\n *\n * @param {Function} fn Original function.\n *\n * @return {Function} Enhanced caching function.\n */\nfunction withWeakMapCache( fn ) {\n\tconst cache = new WeakMap();\n\n\treturn ( key ) => {\n\t\tlet value;\n\t\tif ( cache.has( key ) ) {\n\t\t\tvalue = cache.get( key );\n\t\t} else {\n\t\t\tvalue = fn( key );\n\n\t\t\t// Can reach here if key is not valid for WeakMap, since `has`\n\t\t\t// will return false for invalid key. Since `set` will throw,\n\t\t\t// ensure that key is valid before setting into cache.\n\t\t\tif ( key !== null && typeof key === 'object' ) {\n\t\t\t\tcache.set( key, value );\n\t\t\t}\n\t\t}\n\n\t\treturn value;\n\t};\n}\n\nexport default withWeakMapCache;\n"],
|
|
5
|
-
"mappings": "AASA,SAAS,iBAAkB,IAAK;AAC/B,QAAM,QAAQ,oBAAI,QAAQ;AAE1B,SAAO,CAAE,QAAS;AACjB,QAAI;AACJ,QAAK,MAAM,IAAK,GAAI,GAAI;AACvB,cAAQ,MAAM,IAAK,GAAI;AAAA,IACxB,OAAO;AACN,cAAQ,GAAI,GAAI;AAKhB,UAAK,QAAQ,QAAQ,OAAO,QAAQ,UAAW;AAC9C,cAAM,IAAK,KAAK,KAAM;AAAA,MACvB;AAAA,IACD;AAEA,WAAO;AAAA,EACR;AACD;AAEA,IAAO,8BAAQ;",
|
|
5
|
+
"mappings": ";AASA,SAAS,iBAAkB,IAAK;AAC/B,QAAM,QAAQ,oBAAI,QAAQ;AAE1B,SAAO,CAAE,QAAS;AACjB,QAAI;AACJ,QAAK,MAAM,IAAK,GAAI,GAAI;AACvB,cAAQ,MAAM,IAAK,GAAI;AAAA,IACxB,OAAO;AACN,cAAQ,GAAI,GAAI;AAKhB,UAAK,QAAQ,QAAQ,OAAO,QAAQ,UAAW;AAC9C,cAAM,IAAK,KAAK,KAAM;AAAA,MACvB;AAAA,IACD;AAEA,WAAO;AAAA,EACR;AACD;AAEA,IAAO,8BAAQ;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wordpress/core-data",
|
|
3
|
-
"version": "7.34.0",
|
|
3
|
+
"version": "7.34.1-next.2f1c7c01b.0",
|
|
4
4
|
"description": "Access to and manipulation of core WordPress entities.",
|
|
5
5
|
"author": "The WordPress Contributors",
|
|
6
6
|
"license": "GPL-2.0-or-later",
|
|
@@ -40,22 +40,22 @@
|
|
|
40
40
|
"{src,build,build-module}/index.js"
|
|
41
41
|
],
|
|
42
42
|
"dependencies": {
|
|
43
|
-
"@wordpress/api-fetch": "^7.34.0",
|
|
44
|
-
"@wordpress/block-editor": "^15.7.0",
|
|
45
|
-
"@wordpress/blocks": "^15.7.0",
|
|
46
|
-
"@wordpress/compose": "^7.34.0",
|
|
47
|
-
"@wordpress/data": "^10.34.0",
|
|
48
|
-
"@wordpress/deprecated": "^4.34.0",
|
|
49
|
-
"@wordpress/element": "^6.34.0",
|
|
50
|
-
"@wordpress/html-entities": "^4.34.0",
|
|
51
|
-
"@wordpress/i18n": "^6.7.0",
|
|
52
|
-
"@wordpress/is-shallow-equal": "^5.34.0",
|
|
53
|
-
"@wordpress/private-apis": "^1.34.0",
|
|
54
|
-
"@wordpress/rich-text": "^7.34.0",
|
|
55
|
-
"@wordpress/sync": "^1.34.0",
|
|
56
|
-
"@wordpress/undo-manager": "^1.34.0",
|
|
57
|
-
"@wordpress/url": "^4.34.0",
|
|
58
|
-
"@wordpress/warning": "^3.34.0",
|
|
43
|
+
"@wordpress/api-fetch": "^7.34.1-next.2f1c7c01b.0",
|
|
44
|
+
"@wordpress/block-editor": "^15.7.1-next.2f1c7c01b.0",
|
|
45
|
+
"@wordpress/blocks": "^15.7.1-next.2f1c7c01b.0",
|
|
46
|
+
"@wordpress/compose": "^7.34.1-next.2f1c7c01b.0",
|
|
47
|
+
"@wordpress/data": "^10.34.1-next.2f1c7c01b.0",
|
|
48
|
+
"@wordpress/deprecated": "^4.34.1-next.2f1c7c01b.0",
|
|
49
|
+
"@wordpress/element": "^6.34.1-next.2f1c7c01b.0",
|
|
50
|
+
"@wordpress/html-entities": "^4.34.1-next.2f1c7c01b.0",
|
|
51
|
+
"@wordpress/i18n": "^6.7.1-next.2f1c7c01b.0",
|
|
52
|
+
"@wordpress/is-shallow-equal": "^5.34.1-next.2f1c7c01b.0",
|
|
53
|
+
"@wordpress/private-apis": "^1.34.1-next.2f1c7c01b.0",
|
|
54
|
+
"@wordpress/rich-text": "^7.34.1-next.2f1c7c01b.0",
|
|
55
|
+
"@wordpress/sync": "^1.34.1-next.2f1c7c01b.0",
|
|
56
|
+
"@wordpress/undo-manager": "^1.34.1-next.2f1c7c01b.0",
|
|
57
|
+
"@wordpress/url": "^4.34.1-next.2f1c7c01b.0",
|
|
58
|
+
"@wordpress/warning": "^3.34.1-next.2f1c7c01b.0",
|
|
59
59
|
"change-case": "^4.1.2",
|
|
60
60
|
"equivalent-key-map": "^0.2.2",
|
|
61
61
|
"fast-deep-equal": "^3.1.3",
|
|
@@ -69,5 +69,5 @@
|
|
|
69
69
|
"publishConfig": {
|
|
70
70
|
"access": "public"
|
|
71
71
|
},
|
|
72
|
-
"gitHead": "
|
|
72
|
+
"gitHead": "c6ddcdf455bc02567a2c9e03de6862a2061b85e8"
|
|
73
73
|
}
|
package/src/test/resolvers.js
CHANGED
|
@@ -24,6 +24,7 @@ import {
|
|
|
24
24
|
getAutosaves,
|
|
25
25
|
getCurrentUser,
|
|
26
26
|
} from '../resolvers';
|
|
27
|
+
import { RECEIVE_INTERMEDIATE_RESULTS } from '../utils';
|
|
27
28
|
|
|
28
29
|
describe( 'getEntityRecord', () => {
|
|
29
30
|
const POST_TYPE = { slug: 'post' };
|
|
@@ -326,6 +327,11 @@ describe( 'getEntityRecords', () => {
|
|
|
326
327
|
baseURL: '/wp/v2/posts',
|
|
327
328
|
baseURLParams: { context: 'edit' },
|
|
328
329
|
},
|
|
330
|
+
{
|
|
331
|
+
name: 'attachment',
|
|
332
|
+
kind: 'postType',
|
|
333
|
+
supportsPagination: true,
|
|
334
|
+
},
|
|
329
335
|
];
|
|
330
336
|
const registry = { batch: ( callback ) => callback() };
|
|
331
337
|
const resolveSelect = { getEntitiesConfig: jest.fn( () => ENTITIES ) };
|
|
@@ -516,6 +522,78 @@ describe( 'getEntityRecords', () => {
|
|
|
516
522
|
expect.any( Array )
|
|
517
523
|
);
|
|
518
524
|
} );
|
|
525
|
+
|
|
526
|
+
it( 'provides pagination metadata and progressive loading during intermediate results fetching', async () => {
|
|
527
|
+
const dispatch = Object.assign( jest.fn(), {
|
|
528
|
+
receiveEntityRecords: jest.fn(),
|
|
529
|
+
__unstableAcquireStoreLock: jest.fn(),
|
|
530
|
+
__unstableReleaseStoreLock: jest.fn(),
|
|
531
|
+
finishResolutions: jest.fn(),
|
|
532
|
+
} );
|
|
533
|
+
|
|
534
|
+
const mockPages = [
|
|
535
|
+
[ { id: 1 }, { id: 2 } ],
|
|
536
|
+
[ { id: 3 }, { id: 4 } ],
|
|
537
|
+
[ { id: 5 } ],
|
|
538
|
+
];
|
|
539
|
+
|
|
540
|
+
let callCount = 0;
|
|
541
|
+
triggerFetch.mockImplementation( () => {
|
|
542
|
+
const data = mockPages[ callCount % mockPages.length ];
|
|
543
|
+
callCount++;
|
|
544
|
+
return Promise.resolve( {
|
|
545
|
+
json: () => Promise.resolve( data ),
|
|
546
|
+
headers: new Map( [
|
|
547
|
+
[ 'X-WP-Total', '5' ],
|
|
548
|
+
[ 'X-WP-TotalPages', '3' ],
|
|
549
|
+
] ),
|
|
550
|
+
} );
|
|
551
|
+
} );
|
|
552
|
+
|
|
553
|
+
await getEntityRecords( 'postType', 'attachment', {
|
|
554
|
+
per_page: -1,
|
|
555
|
+
[ RECEIVE_INTERMEDIATE_RESULTS ]: true,
|
|
556
|
+
} )( { dispatch, registry, resolveSelect } );
|
|
557
|
+
|
|
558
|
+
// 3 calls for intermediate results (one per page), plus 1 final call with complete records
|
|
559
|
+
expect( dispatch.receiveEntityRecords ).toHaveBeenCalledTimes( 4 );
|
|
560
|
+
|
|
561
|
+
// Check that the first call already includes pagination metadata
|
|
562
|
+
expect( dispatch.receiveEntityRecords ).toHaveBeenCalledWith(
|
|
563
|
+
'postType',
|
|
564
|
+
'attachment',
|
|
565
|
+
expect.any( Array ),
|
|
566
|
+
{ per_page: -1, [ RECEIVE_INTERMEDIATE_RESULTS ]: true },
|
|
567
|
+
false,
|
|
568
|
+
undefined,
|
|
569
|
+
expect.objectContaining( { totalItems: 5, totalPages: 1 } )
|
|
570
|
+
);
|
|
571
|
+
|
|
572
|
+
// Check that all calls include pagination metadata
|
|
573
|
+
dispatch.receiveEntityRecords.mock.calls.forEach( ( call ) => {
|
|
574
|
+
// 7th parameter is the pagination metadata
|
|
575
|
+
expect( call[ 6 ] ).toEqual(
|
|
576
|
+
expect.objectContaining( { totalItems: 5, totalPages: 1 } )
|
|
577
|
+
);
|
|
578
|
+
} );
|
|
579
|
+
|
|
580
|
+
// Should process all the data from the 3 mock pages (2+2+1=5 records total)
|
|
581
|
+
expect( dispatch.receiveEntityRecords ).toHaveBeenLastCalledWith(
|
|
582
|
+
'postType',
|
|
583
|
+
'attachment',
|
|
584
|
+
expect.arrayContaining( [
|
|
585
|
+
expect.objectContaining( { id: 1 } ),
|
|
586
|
+
expect.objectContaining( { id: 2 } ),
|
|
587
|
+
expect.objectContaining( { id: 3 } ),
|
|
588
|
+
expect.objectContaining( { id: 4 } ),
|
|
589
|
+
expect.objectContaining( { id: 5 } ),
|
|
590
|
+
] ),
|
|
591
|
+
{ per_page: -1, [ RECEIVE_INTERMEDIATE_RESULTS ]: true },
|
|
592
|
+
false,
|
|
593
|
+
undefined,
|
|
594
|
+
expect.objectContaining( { totalItems: 5, totalPages: 1 } )
|
|
595
|
+
);
|
|
596
|
+
} );
|
|
519
597
|
} );
|
|
520
598
|
|
|
521
599
|
describe( 'taxonomy pagination', () => {
|