@wordpress/core-data 7.32.0 → 7.32.1-next.ff1cebbba.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 +375 -632
- package/build/actions.js.map +7 -1
- package/build/batch/create-batch.js +49 -62
- package/build/batch/create-batch.js.map +7 -1
- package/build/batch/default-processor.js +43 -39
- package/build/batch/default-processor.js.map +7 -1
- package/build/batch/index.js +38 -17
- package/build/batch/index.js.map +7 -1
- package/build/dynamic-entities.js +30 -32
- package/build/dynamic-entities.js.map +7 -1
- package/build/entities.js +298 -410
- package/build/entities.js.map +7 -1
- package/build/entity-context.js +29 -12
- package/build/entity-context.js.map +7 -1
- package/build/entity-provider.js +38 -46
- package/build/entity-provider.js.map +7 -1
- package/build/entity-types/attachment.js +16 -5
- package/build/entity-types/attachment.js.map +7 -1
- package/build/entity-types/base-entity-records.js +16 -42
- package/build/entity-types/base-entity-records.js.map +7 -1
- package/build/entity-types/base.js +16 -5
- package/build/entity-types/base.js.map +7 -1
- package/build/entity-types/comment.js +16 -5
- package/build/entity-types/comment.js.map +7 -1
- package/build/entity-types/global-styles-revision.js +16 -5
- package/build/entity-types/global-styles-revision.js.map +7 -1
- package/build/entity-types/helpers.js +16 -5
- package/build/entity-types/helpers.js.map +7 -1
- package/build/entity-types/index.js +16 -5
- package/build/entity-types/index.js.map +7 -1
- package/build/entity-types/menu-location.js +16 -5
- package/build/entity-types/menu-location.js.map +7 -1
- package/build/entity-types/nav-menu-item.js +16 -5
- package/build/entity-types/nav-menu-item.js.map +7 -1
- package/build/entity-types/nav-menu.js +16 -5
- package/build/entity-types/nav-menu.js.map +7 -1
- package/build/entity-types/page.js +16 -5
- package/build/entity-types/page.js.map +7 -1
- package/build/entity-types/plugin.js +16 -5
- package/build/entity-types/plugin.js.map +7 -1
- package/build/entity-types/post-revision.js +16 -5
- package/build/entity-types/post-revision.js.map +7 -1
- package/build/entity-types/post-status.js +16 -5
- package/build/entity-types/post-status.js.map +7 -1
- package/build/entity-types/post.js +16 -5
- package/build/entity-types/post.js.map +7 -1
- package/build/entity-types/settings.js +16 -5
- package/build/entity-types/settings.js.map +7 -1
- package/build/entity-types/sidebar.js +16 -5
- package/build/entity-types/sidebar.js.map +7 -1
- package/build/entity-types/taxonomy.js +16 -5
- package/build/entity-types/taxonomy.js.map +7 -1
- package/build/entity-types/term.js +16 -5
- package/build/entity-types/term.js.map +7 -1
- package/build/entity-types/theme.js +16 -5
- package/build/entity-types/theme.js.map +7 -1
- package/build/entity-types/type.js +16 -5
- package/build/entity-types/type.js.map +7 -1
- package/build/entity-types/user.js +16 -5
- package/build/entity-types/user.js.map +7 -1
- package/build/entity-types/widget-type.js +16 -5
- package/build/entity-types/widget-type.js.map +7 -1
- package/build/entity-types/widget.js +16 -5
- package/build/entity-types/widget.js.map +7 -1
- package/build/entity-types/wp-template-part.js +16 -5
- package/build/entity-types/wp-template-part.js.map +7 -1
- package/build/entity-types/wp-template.js +16 -5
- package/build/entity-types/wp-template.js.map +7 -1
- package/build/fetch/__experimental-fetch-link-suggestions.js +141 -154
- package/build/fetch/__experimental-fetch-link-suggestions.js.map +7 -1
- package/build/fetch/__experimental-fetch-url-data.js +47 -59
- package/build/fetch/__experimental-fetch-url-data.js.map +7 -1
- package/build/fetch/index.js +53 -32
- package/build/fetch/index.js.map +7 -1
- package/build/footnotes/get-footnotes-order.js +38 -25
- package/build/footnotes/get-footnotes-order.js.map +7 -1
- package/build/footnotes/get-rich-text-values-cached.js +26 -27
- package/build/footnotes/get-rich-text-values-cached.js.map +7 -1
- package/build/footnotes/index.js +68 -55
- package/build/footnotes/index.js.map +7 -1
- package/build/hooks/constants.js +33 -12
- package/build/hooks/constants.js.map +7 -1
- package/build/hooks/index.js +59 -68
- package/build/hooks/index.js.map +7 -1
- package/build/hooks/memoize.js +34 -12
- package/build/hooks/memoize.js.map +7 -1
- package/build/hooks/use-entity-block-editor.js +111 -119
- package/build/hooks/use-entity-block-editor.js.map +7 -1
- package/build/hooks/use-entity-id.js +25 -23
- package/build/hooks/use-entity-id.js.map +7 -1
- package/build/hooks/use-entity-prop.js +59 -60
- package/build/hooks/use-entity-prop.js.map +7 -1
- package/build/hooks/use-entity-record.js +95 -155
- package/build/hooks/use-entity-record.js.map +7 -1
- package/build/hooks/use-entity-records.js +131 -139
- package/build/hooks/use-entity-records.js.map +7 -1
- package/build/hooks/use-query-select.js +65 -84
- package/build/hooks/use-query-select.js.map +7 -1
- package/build/hooks/use-resource-permissions.js +92 -145
- package/build/hooks/use-resource-permissions.js.map +7 -1
- package/build/index.js +96 -153
- package/build/index.js.map +7 -1
- package/build/lock-unlock.js +31 -14
- package/build/lock-unlock.js.map +7 -1
- package/build/locks/actions.js +36 -19
- package/build/locks/actions.js.map +7 -1
- package/build/locks/engine.js +48 -47
- package/build/locks/engine.js.map +7 -1
- package/build/locks/reducer.js +54 -63
- package/build/locks/reducer.js.map +7 -1
- package/build/locks/selectors.js +35 -30
- package/build/locks/selectors.js.map +7 -1
- package/build/locks/utils.js +37 -16
- package/build/locks/utils.js.map +7 -1
- package/build/name.js +27 -12
- package/build/name.js.map +7 -1
- package/build/private-actions.js +67 -75
- package/build/private-actions.js.map +7 -1
- package/build/private-apis.js +33 -16
- package/build/private-apis.js.map +7 -1
- package/build/private-selectors.js +204 -184
- package/build/private-selectors.js.map +7 -1
- package/build/queried-data/actions.js +32 -41
- package/build/queried-data/actions.js.map +7 -1
- package/build/queried-data/get-query-parts.js +41 -79
- package/build/queried-data/get-query-parts.js.map +7 -1
- package/build/queried-data/index.js +39 -36
- package/build/queried-data/index.js.map +7 -1
- package/build/queried-data/reducer.js +162 -193
- package/build/queried-data/reducer.js.map +7 -1
- package/build/queried-data/selectors.js +57 -85
- package/build/queried-data/selectors.js.map +7 -1
- package/build/reducer.js +279 -404
- package/build/reducer.js.map +7 -1
- package/build/resolvers.js +553 -600
- package/build/resolvers.js.map +7 -1
- package/build/selectors.js +456 -981
- package/build/selectors.js.map +7 -1
- package/build/sync.js +34 -22
- package/build/sync.js.map +7 -1
- package/build/types.js +16 -5
- package/build/types.js.map +7 -1
- package/build/utils/conservative-map-item.js +34 -27
- package/build/utils/conservative-map-item.js.map +7 -1
- package/build/utils/crdt-blocks.js +289 -0
- package/build/utils/crdt-blocks.js.map +7 -0
- package/build/utils/crdt.js +202 -0
- package/build/utils/crdt.js.map +7 -0
- package/build/utils/forward-resolver.js +24 -16
- package/build/utils/forward-resolver.js.map +7 -1
- package/build/utils/get-nested-value.js +26 -21
- package/build/utils/get-nested-value.js.map +7 -1
- package/build/utils/get-normalized-comma-separable.js +25 -17
- package/build/utils/get-normalized-comma-separable.js.map +7 -1
- package/build/utils/if-matching-action.js +25 -19
- package/build/utils/if-matching-action.js.map +7 -1
- package/build/utils/index.js +77 -108
- package/build/utils/index.js.map +7 -1
- package/build/utils/is-numeric-id.js +22 -12
- package/build/utils/is-numeric-id.js.map +7 -1
- package/build/utils/is-raw-attribute.js +22 -13
- package/build/utils/is-raw-attribute.js.map +7 -1
- package/build/utils/log-entity-deprecation.js +37 -38
- package/build/utils/log-entity-deprecation.js.map +7 -1
- package/build/utils/on-sub-key.js +30 -24
- package/build/utils/on-sub-key.js.map +7 -1
- package/build/utils/receive-intermediate-results.js +29 -6
- package/build/utils/receive-intermediate-results.js.map +7 -1
- package/build/utils/replace-action.js +24 -17
- package/build/utils/replace-action.js.map +7 -1
- package/build/utils/set-nested-value.js +25 -30
- package/build/utils/set-nested-value.js.map +7 -1
- package/build/utils/user-permissions.js +41 -13
- package/build/utils/user-permissions.js.map +7 -1
- package/build/utils/with-weak-map-cache.js +26 -22
- package/build/utils/with-weak-map-cache.js.map +7 -1
- package/build-module/actions.js +322 -601
- package/build-module/actions.js.map +7 -1
- package/build-module/batch/create-batch.js +21 -57
- package/build-module/batch/create-batch.js.map +7 -1
- package/build-module/batch/default-processor.js +14 -33
- package/build-module/batch/default-processor.js.map +7 -1
- package/build-module/batch/index.js +7 -3
- package/build-module/batch/index.js.map +7 -1
- package/build-module/dynamic-entities.js +7 -28
- package/build-module/dynamic-entities.js.map +7 -1
- package/build-module/entities.js +263 -399
- package/build-module/entities.js.map +7 -1
- package/build-module/entity-context.js +7 -7
- package/build-module/entity-context.js.map +7 -1
- package/build-module/entity-provider.js +19 -42
- package/build-module/entity-provider.js.map +7 -1
- package/build-module/entity-types/attachment.js +1 -2
- package/build-module/entity-types/attachment.js.map +7 -1
- package/build-module/entity-types/base-entity-records.js +1 -37
- package/build-module/entity-types/base-entity-records.js.map +7 -1
- package/build-module/entity-types/base.js +1 -2
- package/build-module/entity-types/base.js.map +7 -1
- package/build-module/entity-types/comment.js +1 -2
- package/build-module/entity-types/comment.js.map +7 -1
- package/build-module/entity-types/global-styles-revision.js +1 -2
- package/build-module/entity-types/global-styles-revision.js.map +7 -1
- package/build-module/entity-types/helpers.js +1 -2
- package/build-module/entity-types/helpers.js.map +7 -1
- package/build-module/entity-types/index.js +1 -2
- package/build-module/entity-types/index.js.map +7 -1
- package/build-module/entity-types/menu-location.js +1 -2
- package/build-module/entity-types/menu-location.js.map +7 -1
- package/build-module/entity-types/nav-menu-item.js +1 -2
- package/build-module/entity-types/nav-menu-item.js.map +7 -1
- package/build-module/entity-types/nav-menu.js +1 -2
- package/build-module/entity-types/nav-menu.js.map +7 -1
- package/build-module/entity-types/page.js +1 -2
- package/build-module/entity-types/page.js.map +7 -1
- package/build-module/entity-types/plugin.js +1 -2
- package/build-module/entity-types/plugin.js.map +7 -1
- package/build-module/entity-types/post-revision.js +1 -2
- package/build-module/entity-types/post-revision.js.map +7 -1
- package/build-module/entity-types/post-status.js +1 -2
- package/build-module/entity-types/post-status.js.map +7 -1
- package/build-module/entity-types/post.js +1 -2
- package/build-module/entity-types/post.js.map +7 -1
- package/build-module/entity-types/settings.js +1 -2
- package/build-module/entity-types/settings.js.map +7 -1
- package/build-module/entity-types/sidebar.js +1 -2
- package/build-module/entity-types/sidebar.js.map +7 -1
- package/build-module/entity-types/taxonomy.js +1 -2
- package/build-module/entity-types/taxonomy.js.map +7 -1
- package/build-module/entity-types/term.js +1 -2
- package/build-module/entity-types/term.js.map +7 -1
- package/build-module/entity-types/theme.js +1 -2
- package/build-module/entity-types/theme.js.map +7 -1
- package/build-module/entity-types/type.js +1 -2
- package/build-module/entity-types/type.js.map +7 -1
- package/build-module/entity-types/user.js +1 -2
- package/build-module/entity-types/user.js.map +7 -1
- package/build-module/entity-types/widget-type.js +1 -2
- package/build-module/entity-types/widget-type.js.map +7 -1
- package/build-module/entity-types/widget.js +1 -2
- package/build-module/entity-types/widget.js.map +7 -1
- package/build-module/entity-types/wp-template-part.js +1 -2
- package/build-module/entity-types/wp-template-part.js.map +7 -1
- package/build-module/entity-types/wp-template.js +1 -2
- package/build-module/entity-types/wp-template.js.map +7 -1
- package/build-module/fetch/__experimental-fetch-link-suggestions.js +111 -149
- package/build-module/fetch/__experimental-fetch-link-suggestions.js.map +7 -1
- package/build-module/fetch/__experimental-fetch-url-data.js +20 -49
- package/build-module/fetch/__experimental-fetch-url-data.js.map +7 -1
- package/build-module/fetch/index.js +20 -15
- package/build-module/fetch/index.js.map +7 -1
- package/build-module/footnotes/get-footnotes-order.js +10 -19
- package/build-module/footnotes/get-footnotes-order.js.map +7 -1
- package/build-module/footnotes/get-rich-text-values-cached.js +8 -23
- package/build-module/footnotes/get-rich-text-values-cached.js.map +7 -1
- package/build-module/footnotes/index.js +34 -47
- package/build-module/footnotes/index.js.map +7 -1
- package/build-module/hooks/constants.js +11 -8
- package/build-module/hooks/constants.js.map +7 -1
- package/build-module/hooks/index.js +27 -15
- package/build-module/hooks/index.js.map +7 -1
- package/build-module/hooks/memoize.js +6 -8
- package/build-module/hooks/memoize.js.map +7 -1
- package/build-module/hooks/use-entity-block-editor.js +80 -110
- package/build-module/hooks/use-entity-block-editor.js.map +7 -1
- package/build-module/hooks/use-entity-id.js +7 -19
- package/build-module/hooks/use-entity-id.js.map +7 -1
- package/build-module/hooks/use-entity-prop.js +31 -55
- package/build-module/hooks/use-entity-prop.js.map +7 -1
- package/build-module/hooks/use-entity-record.js +63 -148
- package/build-module/hooks/use-entity-record.js.map +7 -1
- package/build-module/hooks/use-entity-records.js +98 -131
- package/build-module/hooks/use-entity-records.js.map +7 -1
- package/build-module/hooks/use-query-select.js +27 -71
- package/build-module/hooks/use-query-select.js.map +7 -1
- package/build-module/hooks/use-resource-permissions.js +57 -136
- package/build-module/hooks/use-resource-permissions.js.map +7 -1
- package/build-module/index.js +49 -71
- package/build-module/index.js.map +7 -1
- package/build-module/lock-unlock.js +8 -7
- package/build-module/lock-unlock.js.map +7 -1
- package/build-module/locks/actions.js +8 -13
- package/build-module/locks/actions.js.map +7 -1
- package/build-module/locks/engine.js +17 -38
- package/build-module/locks/engine.js.map +7 -1
- package/build-module/locks/reducer.js +37 -59
- package/build-module/locks/reducer.js.map +7 -1
- package/build-module/locks/selectors.js +16 -23
- package/build-module/locks/selectors.js.map +7 -1
- package/build-module/locks/utils.js +15 -12
- package/build-module/locks/utils.js.map +7 -1
- package/build-module/name.js +5 -8
- package/build-module/name.js.map +7 -1
- package/build-module/private-actions.js +35 -69
- package/build-module/private-actions.js.map +7 -1
- package/build-module/private-apis.js +8 -8
- package/build-module/private-apis.js.map +7 -1
- package/build-module/private-selectors.js +167 -174
- package/build-module/private-selectors.js.map +7 -1
- package/build-module/queried-data/actions.js +11 -38
- package/build-module/queried-data/actions.js.map +7 -1
- package/build-module/queried-data/get-query-parts.js +20 -75
- package/build-module/queried-data/get-query-parts.js.map +7 -1
- package/build-module/queried-data/index.js +7 -4
- package/build-module/queried-data/index.js.map +7 -1
- package/build-module/queried-data/reducer.js +134 -185
- package/build-module/queried-data/reducer.js.map +7 -1
- package/build-module/queried-data/selectors.js +23 -78
- package/build-module/queried-data/selectors.js.map +7 -1
- package/build-module/reducer.js +243 -393
- package/build-module/reducer.js.map +7 -1
- package/build-module/resolvers.js +478 -549
- package/build-module/resolvers.js.map +7 -1
- package/build-module/selectors.js +410 -953
- package/build-module/selectors.js.map +7 -1
- package/build-module/sync.js +14 -17
- package/build-module/sync.js.map +7 -1
- package/build-module/types.js +1 -2
- package/build-module/types.js.map +7 -1
- package/build-module/utils/conservative-map-item.js +6 -22
- package/build-module/utils/conservative-map-item.js.map +7 -1
- package/build-module/utils/crdt-blocks.js +255 -0
- package/build-module/utils/crdt-blocks.js.map +7 -0
- package/build-module/utils/crdt.js +167 -0
- package/build-module/utils/crdt.js.map +7 -0
- package/build-module/utils/forward-resolver.js +6 -12
- package/build-module/utils/forward-resolver.js.map +7 -1
- package/build-module/utils/get-nested-value.js +9 -18
- package/build-module/utils/get-nested-value.js.map +7 -1
- package/build-module/utils/get-normalized-comma-separable.js +7 -13
- package/build-module/utils/get-normalized-comma-separable.js.map +7 -1
- package/build-module/utils/if-matching-action.js +7 -15
- package/build-module/utils/if-matching-action.js.map +7 -1
- package/build-module/utils/index.js +35 -14
- package/build-module/utils/index.js.map +7 -1
- package/build-module/utils/is-numeric-id.js +5 -9
- package/build-module/utils/is-numeric-id.js.map +7 -1
- package/build-module/utils/is-raw-attribute.js +5 -10
- package/build-module/utils/is-raw-attribute.js.map +7 -1
- package/build-module/utils/log-entity-deprecation.js +8 -31
- package/build-module/utils/log-entity-deprecation.js.map +7 -1
- package/build-module/utils/on-sub-key.js +8 -19
- package/build-module/utils/on-sub-key.js.map +7 -1
- package/build-module/utils/receive-intermediate-results.js +7 -2
- package/build-module/utils/receive-intermediate-results.js.map +7 -1
- package/build-module/utils/replace-action.js +6 -13
- package/build-module/utils/replace-action.js.map +7 -1
- package/build-module/utils/set-nested-value.js +8 -27
- package/build-module/utils/set-nested-value.js.map +7 -1
- package/build-module/utils/user-permissions.js +19 -9
- package/build-module/utils/user-permissions.js.map +7 -1
- package/build-module/utils/with-weak-map-cache.js +8 -18
- package/build-module/utils/with-weak-map-cache.js.map +7 -1
- package/build-types/actions.d.ts.map +1 -1
- package/build-types/entities.d.ts +0 -56
- package/build-types/entities.d.ts.map +1 -1
- package/build-types/index.d.ts.map +1 -1
- package/build-types/private-selectors.d.ts.map +1 -1
- package/build-types/resolvers.d.ts +3 -0
- package/build-types/resolvers.d.ts.map +1 -1
- package/build-types/selectors.d.ts.map +1 -1
- package/build-types/sync.d.ts +6 -1
- package/build-types/sync.d.ts.map +1 -1
- package/build-types/types.d.ts +9 -0
- package/build-types/types.d.ts.map +1 -1
- package/build-types/utils/crdt-blocks.d.ts +30 -0
- package/build-types/utils/crdt-blocks.d.ts.map +1 -0
- package/build-types/utils/crdt.d.ts +49 -0
- package/build-types/utils/crdt.d.ts.map +1 -0
- package/package.json +26 -19
- package/src/actions.js +56 -74
- package/src/entities.js +59 -113
- package/src/private-selectors.ts +32 -7
- package/src/resolvers.js +173 -120
- package/src/selectors.ts +0 -13
- package/src/sync.ts +12 -0
- package/src/test/resolvers.js +183 -0
- package/src/types.ts +12 -0
- package/src/utils/crdt-blocks.ts +503 -0
- package/src/utils/crdt.ts +310 -0
- package/src/utils/test/crdt-blocks.ts +375 -0
- package/src/utils/test/crdt.ts +254 -0
- package/tsconfig.tsbuildinfo +1 -1
- package/src/sync.js +0 -27
package/build/selectors.js
CHANGED
|
@@ -1,333 +1,203 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
var
|
|
4
|
-
Object.
|
|
5
|
-
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
var selectors_exports = {};
|
|
30
|
+
__export(selectors_exports, {
|
|
31
|
+
__experimentalGetCurrentGlobalStylesId: () => __experimentalGetCurrentGlobalStylesId,
|
|
32
|
+
__experimentalGetCurrentThemeBaseGlobalStyles: () => __experimentalGetCurrentThemeBaseGlobalStyles,
|
|
33
|
+
__experimentalGetCurrentThemeGlobalStylesVariations: () => __experimentalGetCurrentThemeGlobalStylesVariations,
|
|
34
|
+
__experimentalGetDirtyEntityRecords: () => __experimentalGetDirtyEntityRecords,
|
|
35
|
+
__experimentalGetEntitiesBeingSaved: () => __experimentalGetEntitiesBeingSaved,
|
|
36
|
+
__experimentalGetEntityRecordNoResolver: () => __experimentalGetEntityRecordNoResolver,
|
|
37
|
+
canUser: () => canUser,
|
|
38
|
+
canUserEditEntityRecord: () => canUserEditEntityRecord,
|
|
39
|
+
getAuthors: () => getAuthors,
|
|
40
|
+
getAutosave: () => getAutosave,
|
|
41
|
+
getAutosaves: () => getAutosaves,
|
|
42
|
+
getBlockPatternCategories: () => getBlockPatternCategories,
|
|
43
|
+
getBlockPatterns: () => getBlockPatterns,
|
|
44
|
+
getCurrentTheme: () => getCurrentTheme,
|
|
45
|
+
getCurrentThemeGlobalStylesRevisions: () => getCurrentThemeGlobalStylesRevisions,
|
|
46
|
+
getCurrentUser: () => getCurrentUser,
|
|
47
|
+
getDefaultTemplateId: () => getDefaultTemplateId,
|
|
48
|
+
getEditedEntityRecord: () => getEditedEntityRecord,
|
|
49
|
+
getEmbedPreview: () => getEmbedPreview,
|
|
50
|
+
getEntitiesByKind: () => getEntitiesByKind,
|
|
51
|
+
getEntitiesConfig: () => getEntitiesConfig,
|
|
52
|
+
getEntity: () => getEntity,
|
|
53
|
+
getEntityConfig: () => getEntityConfig,
|
|
54
|
+
getEntityRecord: () => getEntityRecord,
|
|
55
|
+
getEntityRecordEdits: () => getEntityRecordEdits,
|
|
56
|
+
getEntityRecordNonTransientEdits: () => getEntityRecordNonTransientEdits,
|
|
57
|
+
getEntityRecords: () => getEntityRecords,
|
|
58
|
+
getEntityRecordsTotalItems: () => getEntityRecordsTotalItems,
|
|
59
|
+
getEntityRecordsTotalPages: () => getEntityRecordsTotalPages,
|
|
60
|
+
getLastEntityDeleteError: () => getLastEntityDeleteError,
|
|
61
|
+
getLastEntitySaveError: () => getLastEntitySaveError,
|
|
62
|
+
getRawEntityRecord: () => getRawEntityRecord,
|
|
63
|
+
getRedoEdit: () => getRedoEdit,
|
|
64
|
+
getReferenceByDistinctEdits: () => getReferenceByDistinctEdits,
|
|
65
|
+
getRevision: () => getRevision,
|
|
66
|
+
getRevisions: () => getRevisions,
|
|
67
|
+
getThemeSupports: () => getThemeSupports,
|
|
68
|
+
getUndoEdit: () => getUndoEdit,
|
|
69
|
+
getUserPatternCategories: () => getUserPatternCategories,
|
|
70
|
+
getUserQueryResults: () => getUserQueryResults,
|
|
71
|
+
hasEditsForEntityRecord: () => hasEditsForEntityRecord,
|
|
72
|
+
hasEntityRecord: () => hasEntityRecord,
|
|
73
|
+
hasEntityRecords: () => hasEntityRecords,
|
|
74
|
+
hasFetchedAutosaves: () => hasFetchedAutosaves,
|
|
75
|
+
hasRedo: () => hasRedo,
|
|
76
|
+
hasUndo: () => hasUndo,
|
|
77
|
+
isAutosavingEntityRecord: () => isAutosavingEntityRecord,
|
|
78
|
+
isDeletingEntityRecord: () => isDeletingEntityRecord,
|
|
79
|
+
isPreviewEmbedFallback: () => isPreviewEmbedFallback,
|
|
80
|
+
isRequestingEmbedPreview: () => isRequestingEmbedPreview,
|
|
81
|
+
isSavingEntityRecord: () => isSavingEntityRecord
|
|
6
82
|
});
|
|
7
|
-
exports
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
exports.getAutosaves = getAutosaves;
|
|
17
|
-
exports.getBlockPatternCategories = getBlockPatternCategories;
|
|
18
|
-
exports.getBlockPatterns = getBlockPatterns;
|
|
19
|
-
exports.getCurrentTheme = getCurrentTheme;
|
|
20
|
-
exports.getCurrentThemeGlobalStylesRevisions = getCurrentThemeGlobalStylesRevisions;
|
|
21
|
-
exports.getCurrentUser = getCurrentUser;
|
|
22
|
-
exports.getDefaultTemplateId = getDefaultTemplateId;
|
|
23
|
-
exports.getEditedEntityRecord = void 0;
|
|
24
|
-
exports.getEmbedPreview = getEmbedPreview;
|
|
25
|
-
exports.getEntitiesByKind = getEntitiesByKind;
|
|
26
|
-
exports.getEntitiesConfig = void 0;
|
|
27
|
-
exports.getEntity = getEntity;
|
|
28
|
-
exports.getEntityConfig = getEntityConfig;
|
|
29
|
-
exports.getEntityRecord = void 0;
|
|
30
|
-
exports.getEntityRecordEdits = getEntityRecordEdits;
|
|
31
|
-
exports.getEntityRecordsTotalPages = exports.getEntityRecordsTotalItems = exports.getEntityRecords = exports.getEntityRecordNonTransientEdits = void 0;
|
|
32
|
-
exports.getLastEntityDeleteError = getLastEntityDeleteError;
|
|
33
|
-
exports.getLastEntitySaveError = getLastEntitySaveError;
|
|
34
|
-
exports.getRawEntityRecord = void 0;
|
|
35
|
-
exports.getRedoEdit = getRedoEdit;
|
|
36
|
-
exports.getReferenceByDistinctEdits = getReferenceByDistinctEdits;
|
|
37
|
-
exports.getRevisions = exports.getRevision = void 0;
|
|
38
|
-
exports.getThemeSupports = getThemeSupports;
|
|
39
|
-
exports.getUndoEdit = getUndoEdit;
|
|
40
|
-
exports.getUserPatternCategories = getUserPatternCategories;
|
|
41
|
-
exports.getUserQueryResults = void 0;
|
|
42
|
-
exports.hasEditsForEntityRecord = hasEditsForEntityRecord;
|
|
43
|
-
exports.hasEntityRecord = hasEntityRecord;
|
|
44
|
-
exports.hasEntityRecords = hasEntityRecords;
|
|
45
|
-
exports.hasFetchedAutosaves = void 0;
|
|
46
|
-
exports.hasRedo = hasRedo;
|
|
47
|
-
exports.hasUndo = hasUndo;
|
|
48
|
-
exports.isAutosavingEntityRecord = isAutosavingEntityRecord;
|
|
49
|
-
exports.isDeletingEntityRecord = isDeletingEntityRecord;
|
|
50
|
-
exports.isPreviewEmbedFallback = isPreviewEmbedFallback;
|
|
51
|
-
exports.isRequestingEmbedPreview = void 0;
|
|
52
|
-
exports.isSavingEntityRecord = isSavingEntityRecord;
|
|
53
|
-
var _data = require("@wordpress/data");
|
|
54
|
-
var _url = require("@wordpress/url");
|
|
55
|
-
var _deprecated = _interopRequireDefault(require("@wordpress/deprecated"));
|
|
56
|
-
var _name = require("./name");
|
|
57
|
-
var _queriedData = require("./queried-data");
|
|
58
|
-
var _entities = require("./entities");
|
|
59
|
-
var _utils = require("./utils");
|
|
60
|
-
var _logEntityDeprecation = _interopRequireDefault(require("./utils/log-entity-deprecation"));
|
|
61
|
-
/**
|
|
62
|
-
* WordPress dependencies
|
|
63
|
-
*/
|
|
64
|
-
|
|
65
|
-
/**
|
|
66
|
-
* Internal dependencies
|
|
67
|
-
*/
|
|
68
|
-
|
|
69
|
-
// This is an incomplete, high-level approximation of the State type.
|
|
70
|
-
// It makes the selectors slightly more safe, but is intended to evolve
|
|
71
|
-
// into a more detailed representation over time.
|
|
72
|
-
// See https://github.com/WordPress/gutenberg/pull/40025#discussion_r865410589 for more context.
|
|
73
|
-
|
|
74
|
-
/**
|
|
75
|
-
* HTTP Query parameters sent with the API request to fetch the entity records.
|
|
76
|
-
*/
|
|
77
|
-
|
|
78
|
-
/**
|
|
79
|
-
* Arguments for EntityRecord selectors.
|
|
80
|
-
*/
|
|
81
|
-
|
|
82
|
-
/**
|
|
83
|
-
* Shared reference to an empty object for cases where it is important to avoid
|
|
84
|
-
* returning a new object reference on every invocation, as in a connected or
|
|
85
|
-
* other pure component which performs `shouldComponentUpdate` check on props.
|
|
86
|
-
* This should be used as a last resort, since the normalized data should be
|
|
87
|
-
* maintained by the reducer result in state.
|
|
88
|
-
*/
|
|
83
|
+
module.exports = __toCommonJS(selectors_exports);
|
|
84
|
+
var import_data = require("@wordpress/data");
|
|
85
|
+
var import_url = require("@wordpress/url");
|
|
86
|
+
var import_deprecated = __toESM(require("@wordpress/deprecated"));
|
|
87
|
+
var import_name = require("./name");
|
|
88
|
+
var import_queried_data = require("./queried-data");
|
|
89
|
+
var import_entities = require("./entities");
|
|
90
|
+
var import_utils = require("./utils");
|
|
91
|
+
var import_log_entity_deprecation = __toESM(require("./utils/log-entity-deprecation"));
|
|
89
92
|
const EMPTY_OBJECT = {};
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
*
|
|
98
|
-
* @return Whether a request is in progress for an embed preview.
|
|
99
|
-
*/
|
|
100
|
-
const isRequestingEmbedPreview = exports.isRequestingEmbedPreview = (0, _data.createRegistrySelector)(select => (state, url) => {
|
|
101
|
-
return select(_name.STORE_NAME).isResolving('getEmbedPreview', [url]);
|
|
102
|
-
});
|
|
103
|
-
|
|
104
|
-
/**
|
|
105
|
-
* Returns all available authors.
|
|
106
|
-
*
|
|
107
|
-
* @deprecated since 11.3. Callers should use `select( 'core' ).getUsers({ who: 'authors' })` instead.
|
|
108
|
-
*
|
|
109
|
-
* @param state Data state.
|
|
110
|
-
* @param query Optional object of query parameters to
|
|
111
|
-
* include with request. For valid query parameters see the [Users page](https://developer.wordpress.org/rest-api/reference/users/) in the REST API Handbook and see the arguments for [List Users](https://developer.wordpress.org/rest-api/reference/users/#list-users) and [Retrieve a User](https://developer.wordpress.org/rest-api/reference/users/#retrieve-a-user).
|
|
112
|
-
* @return Authors list.
|
|
113
|
-
*/
|
|
93
|
+
const isRequestingEmbedPreview = (0, import_data.createRegistrySelector)(
|
|
94
|
+
(select) => (state, url) => {
|
|
95
|
+
return select(import_name.STORE_NAME).isResolving("getEmbedPreview", [
|
|
96
|
+
url
|
|
97
|
+
]);
|
|
98
|
+
}
|
|
99
|
+
);
|
|
114
100
|
function getAuthors(state, query) {
|
|
115
|
-
(0,
|
|
116
|
-
since:
|
|
101
|
+
(0, import_deprecated.default)("select( 'core' ).getAuthors()", {
|
|
102
|
+
since: "5.9",
|
|
117
103
|
alternative: "select( 'core' ).getUsers({ who: 'authors' })"
|
|
118
104
|
});
|
|
119
|
-
const path = (0,
|
|
105
|
+
const path = (0, import_url.addQueryArgs)(
|
|
106
|
+
"/wp/v2/users/?who=authors&per_page=100",
|
|
107
|
+
query
|
|
108
|
+
);
|
|
120
109
|
return getUserQueryResults(state, path);
|
|
121
110
|
}
|
|
122
|
-
|
|
123
|
-
/**
|
|
124
|
-
* Returns the current user.
|
|
125
|
-
*
|
|
126
|
-
* @param state Data state.
|
|
127
|
-
*
|
|
128
|
-
* @return Current user object.
|
|
129
|
-
*/
|
|
130
111
|
function getCurrentUser(state) {
|
|
131
112
|
return state.currentUser;
|
|
132
113
|
}
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
var _state$users$queries$;
|
|
144
|
-
const queryResults = (_state$users$queries$ = state.users.queries[queryID]) !== null && _state$users$queries$ !== void 0 ? _state$users$queries$ : [];
|
|
145
|
-
return queryResults.map(id => state.users.byId[id]);
|
|
146
|
-
}, (state, queryID) => [state.users.queries[queryID], state.users.byId]);
|
|
147
|
-
|
|
148
|
-
/**
|
|
149
|
-
* Returns the loaded entities for the given kind.
|
|
150
|
-
*
|
|
151
|
-
* @deprecated since WordPress 6.0. Use getEntitiesConfig instead
|
|
152
|
-
* @param state Data state.
|
|
153
|
-
* @param kind Entity kind.
|
|
154
|
-
*
|
|
155
|
-
* @return Array of entities with config matching kind.
|
|
156
|
-
*/
|
|
114
|
+
const getUserQueryResults = (0, import_data.createSelector)(
|
|
115
|
+
(state, queryID) => {
|
|
116
|
+
const queryResults = state.users.queries[queryID] ?? [];
|
|
117
|
+
return queryResults.map((id) => state.users.byId[id]);
|
|
118
|
+
},
|
|
119
|
+
(state, queryID) => [
|
|
120
|
+
state.users.queries[queryID],
|
|
121
|
+
state.users.byId
|
|
122
|
+
]
|
|
123
|
+
);
|
|
157
124
|
function getEntitiesByKind(state, kind) {
|
|
158
|
-
(0,
|
|
159
|
-
since:
|
|
125
|
+
(0, import_deprecated.default)("wp.data.select( 'core' ).getEntitiesByKind()", {
|
|
126
|
+
since: "6.0",
|
|
160
127
|
alternative: "wp.data.select( 'core' ).getEntitiesConfig()"
|
|
161
128
|
});
|
|
162
129
|
return getEntitiesConfig(state, kind);
|
|
163
130
|
}
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
*
|
|
171
|
-
* @return Array of entities with config matching kind.
|
|
172
|
-
*/
|
|
173
|
-
const getEntitiesConfig = exports.getEntitiesConfig = (0, _data.createSelector)((state, kind) => state.entities.config.filter(entity => entity.kind === kind), /* eslint-disable @typescript-eslint/no-unused-vars */
|
|
174
|
-
(state, kind) => state.entities.config
|
|
175
|
-
/* eslint-enable @typescript-eslint/no-unused-vars */);
|
|
176
|
-
/**
|
|
177
|
-
* Returns the entity config given its kind and name.
|
|
178
|
-
*
|
|
179
|
-
* @deprecated since WordPress 6.0. Use getEntityConfig instead
|
|
180
|
-
* @param state Data state.
|
|
181
|
-
* @param kind Entity kind.
|
|
182
|
-
* @param name Entity name.
|
|
183
|
-
*
|
|
184
|
-
* @return Entity config
|
|
185
|
-
*/
|
|
131
|
+
const getEntitiesConfig = (0, import_data.createSelector)(
|
|
132
|
+
(state, kind) => state.entities.config.filter((entity) => entity.kind === kind),
|
|
133
|
+
/* eslint-disable @typescript-eslint/no-unused-vars */
|
|
134
|
+
(state, kind) => state.entities.config
|
|
135
|
+
/* eslint-enable @typescript-eslint/no-unused-vars */
|
|
136
|
+
);
|
|
186
137
|
function getEntity(state, kind, name) {
|
|
187
|
-
(0,
|
|
188
|
-
since:
|
|
138
|
+
(0, import_deprecated.default)("wp.data.select( 'core' ).getEntity()", {
|
|
139
|
+
since: "6.0",
|
|
189
140
|
alternative: "wp.data.select( 'core' ).getEntityConfig()"
|
|
190
141
|
});
|
|
191
142
|
return getEntityConfig(state, kind, name);
|
|
192
143
|
}
|
|
193
|
-
|
|
194
|
-
/**
|
|
195
|
-
* Returns the entity config given its kind and name.
|
|
196
|
-
*
|
|
197
|
-
* @param state Data state.
|
|
198
|
-
* @param kind Entity kind.
|
|
199
|
-
* @param name Entity name.
|
|
200
|
-
*
|
|
201
|
-
* @return Entity config
|
|
202
|
-
*/
|
|
203
144
|
function getEntityConfig(state, kind, name) {
|
|
204
|
-
(0,
|
|
205
|
-
return state.entities.config?.find(
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
* ? ( ...args: P ) => R
|
|
216
|
-
* : F;
|
|
217
|
-
* type Selector = <K extends string | number>(
|
|
218
|
-
* state: any,
|
|
219
|
-
* kind: K,
|
|
220
|
-
* key: K extends string ? 'string value' : false
|
|
221
|
-
* ) => K;
|
|
222
|
-
* type BadlyInferredSignature = CurriedState< Selector >
|
|
223
|
-
* // BadlyInferredSignature evaluates to:
|
|
224
|
-
* // (kind: string number, key: false | "string value") => string number
|
|
225
|
-
* ```
|
|
226
|
-
*
|
|
227
|
-
* The signature without the state parameter shipped as CurriedSignature
|
|
228
|
-
* is used in the return value of `select( coreStore )`.
|
|
229
|
-
*
|
|
230
|
-
* See https://github.com/WordPress/gutenberg/pull/41578 for more details.
|
|
231
|
-
*/
|
|
232
|
-
|
|
233
|
-
/**
|
|
234
|
-
* Returns the Entity's record object by key. Returns `null` if the value is not
|
|
235
|
-
* yet received, undefined if the value entity is known to not exist, or the
|
|
236
|
-
* entity object if it exists and is received.
|
|
237
|
-
*
|
|
238
|
-
* @param state State tree
|
|
239
|
-
* @param kind Entity kind.
|
|
240
|
-
* @param name Entity name.
|
|
241
|
-
* @param key Optional record's key. If requesting a global record (e.g. site settings), the key can be omitted. If requesting a specific item, the key must always be included.
|
|
242
|
-
* @param query Optional query. If requesting specific
|
|
243
|
-
* fields, fields must always include the ID. For valid query parameters see the [Reference](https://developer.wordpress.org/rest-api/reference/) in the REST API Handbook and select the entity kind. Then see the arguments available "Retrieve a [Entity kind]".
|
|
244
|
-
*
|
|
245
|
-
* @return Record.
|
|
246
|
-
*/
|
|
247
|
-
const getEntityRecord = exports.getEntityRecord = (0, _data.createSelector)((state, kind, name, key, query) => {
|
|
248
|
-
var _query$context, _getNormalizedCommaSe;
|
|
249
|
-
(0, _logEntityDeprecation.default)(kind, name, 'getEntityRecord');
|
|
250
|
-
|
|
251
|
-
// For back-compat, we allow querying for static templates through
|
|
252
|
-
// wp_template.
|
|
253
|
-
if (kind === 'postType' && name === 'wp_template' && typeof key === 'string' &&
|
|
254
|
-
// __experimentalGetDirtyEntityRecords always calls getEntityRecord
|
|
255
|
-
// with a string key, so we need that it's not a numeric ID.
|
|
256
|
-
!/^\d+$/.test(key)) {
|
|
257
|
-
name = 'wp_registered_template';
|
|
258
|
-
}
|
|
259
|
-
const queriedState = state.entities.records?.[kind]?.[name]?.queriedData;
|
|
260
|
-
if (!queriedState) {
|
|
261
|
-
return undefined;
|
|
262
|
-
}
|
|
263
|
-
const context = (_query$context = query?.context) !== null && _query$context !== void 0 ? _query$context : 'default';
|
|
264
|
-
if (!query || !query._fields) {
|
|
265
|
-
// If expecting a complete item, validate that completeness.
|
|
266
|
-
if (!queriedState.itemIsComplete[context]?.[key]) {
|
|
267
|
-
return undefined;
|
|
145
|
+
(0, import_log_entity_deprecation.default)(kind, name, "getEntityConfig");
|
|
146
|
+
return state.entities.config?.find(
|
|
147
|
+
(config) => config.kind === kind && config.name === name
|
|
148
|
+
);
|
|
149
|
+
}
|
|
150
|
+
const getEntityRecord = (0, import_data.createSelector)(
|
|
151
|
+
((state, kind, name, key, query) => {
|
|
152
|
+
(0, import_log_entity_deprecation.default)(kind, name, "getEntityRecord");
|
|
153
|
+
const queriedState = state.entities.records?.[kind]?.[name]?.queriedData;
|
|
154
|
+
if (!queriedState) {
|
|
155
|
+
return void 0;
|
|
268
156
|
}
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
157
|
+
const context = query?.context ?? "default";
|
|
158
|
+
if (!query || !query._fields) {
|
|
159
|
+
if (!queriedState.itemIsComplete[context]?.[key]) {
|
|
160
|
+
return void 0;
|
|
161
|
+
}
|
|
162
|
+
return queriedState.items[context][key];
|
|
163
|
+
}
|
|
164
|
+
const item = queriedState.items[context]?.[key];
|
|
165
|
+
if (!item) {
|
|
166
|
+
return item;
|
|
167
|
+
}
|
|
168
|
+
const filteredItem = {};
|
|
169
|
+
const fields = (0, import_utils.getNormalizedCommaSeparable)(query._fields) ?? [];
|
|
170
|
+
for (let f = 0; f < fields.length; f++) {
|
|
171
|
+
const field = fields[f].split(".");
|
|
172
|
+
let value = item;
|
|
173
|
+
field.forEach((fieldName) => {
|
|
174
|
+
value = value?.[fieldName];
|
|
175
|
+
});
|
|
176
|
+
(0, import_utils.setNestedValue)(filteredItem, field, value);
|
|
177
|
+
}
|
|
178
|
+
return filteredItem;
|
|
179
|
+
}),
|
|
180
|
+
(state, kind, name, recordId, query) => {
|
|
181
|
+
const context = query?.context ?? "default";
|
|
182
|
+
const queriedState = state.entities.records?.[kind]?.[name]?.queriedData;
|
|
183
|
+
return [
|
|
184
|
+
queriedState?.items[context]?.[recordId],
|
|
185
|
+
queriedState?.itemIsComplete[context]?.[recordId]
|
|
186
|
+
];
|
|
284
187
|
}
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
var _query$context2;
|
|
288
|
-
const context = (_query$context2 = query?.context) !== null && _query$context2 !== void 0 ? _query$context2 : 'default';
|
|
289
|
-
const queriedState = state.entities.records?.[kind]?.[name]?.queriedData;
|
|
290
|
-
return [queriedState?.items[context]?.[recordId], queriedState?.itemIsComplete[context]?.[recordId]];
|
|
291
|
-
});
|
|
292
|
-
|
|
293
|
-
/**
|
|
294
|
-
* Normalizes `recordKey`s that look like numeric IDs to numbers.
|
|
295
|
-
*
|
|
296
|
-
* @param args EntityRecordArgs the selector arguments.
|
|
297
|
-
* @return EntityRecordArgs the normalized arguments.
|
|
298
|
-
*/
|
|
299
|
-
getEntityRecord.__unstableNormalizeArgs = args => {
|
|
188
|
+
);
|
|
189
|
+
getEntityRecord.__unstableNormalizeArgs = (args) => {
|
|
300
190
|
const newArgs = [...args];
|
|
301
191
|
const recordKey = newArgs?.[2];
|
|
302
|
-
|
|
303
|
-
// If recordKey looks to be a numeric ID then coerce to number.
|
|
304
|
-
newArgs[2] = (0, _utils.isNumericID)(recordKey) ? Number(recordKey) : recordKey;
|
|
192
|
+
newArgs[2] = (0, import_utils.isNumericID)(recordKey) ? Number(recordKey) : recordKey;
|
|
305
193
|
return newArgs;
|
|
306
194
|
};
|
|
307
|
-
|
|
308
|
-
/**
|
|
309
|
-
* Returns true if a record has been received for the given set of parameters, or false otherwise.
|
|
310
|
-
*
|
|
311
|
-
* Note: This action does not trigger a request for the entity record from the API
|
|
312
|
-
* if it's not available in the local state.
|
|
313
|
-
*
|
|
314
|
-
* @param state State tree
|
|
315
|
-
* @param kind Entity kind.
|
|
316
|
-
* @param name Entity name.
|
|
317
|
-
* @param key Record's key.
|
|
318
|
-
* @param query Optional query.
|
|
319
|
-
*
|
|
320
|
-
* @return Whether an entity record has been received.
|
|
321
|
-
*/
|
|
322
195
|
function hasEntityRecord(state, kind, name, key, query) {
|
|
323
|
-
var _query$context3, _getNormalizedCommaSe2;
|
|
324
196
|
const queriedState = state.entities.records?.[kind]?.[name]?.queriedData;
|
|
325
197
|
if (!queriedState) {
|
|
326
198
|
return false;
|
|
327
199
|
}
|
|
328
|
-
const context =
|
|
329
|
-
|
|
330
|
-
// If expecting a complete item, validate that completeness.
|
|
200
|
+
const context = query?.context ?? "default";
|
|
331
201
|
if (!query || !query._fields) {
|
|
332
202
|
return !!queriedState.itemIsComplete[context]?.[key];
|
|
333
203
|
}
|
|
@@ -335,12 +205,9 @@ function hasEntityRecord(state, kind, name, key, query) {
|
|
|
335
205
|
if (!item) {
|
|
336
206
|
return false;
|
|
337
207
|
}
|
|
338
|
-
|
|
339
|
-
// When `query._fields` is provided, check that each requested field exists,
|
|
340
|
-
// including any nested paths, on the item; return false if any part is missing.
|
|
341
|
-
const fields = (_getNormalizedCommaSe2 = (0, _utils.getNormalizedCommaSeparable)(query._fields)) !== null && _getNormalizedCommaSe2 !== void 0 ? _getNormalizedCommaSe2 : [];
|
|
208
|
+
const fields = (0, import_utils.getNormalizedCommaSeparable)(query._fields) ?? [];
|
|
342
209
|
for (let i = 0; i < fields.length; i++) {
|
|
343
|
-
const path = fields[i].split(
|
|
210
|
+
const path = fields[i].split(".");
|
|
344
211
|
let value = item;
|
|
345
212
|
for (let p = 0; p < path.length; p++) {
|
|
346
213
|
const part = path[p];
|
|
@@ -352,141 +219,58 @@ function hasEntityRecord(state, kind, name, key, query) {
|
|
|
352
219
|
}
|
|
353
220
|
return true;
|
|
354
221
|
}
|
|
355
|
-
|
|
356
|
-
/**
|
|
357
|
-
* Returns the Entity's record object by key. Doesn't trigger a resolver nor requests the entity records from the API if the entity record isn't available in the local state.
|
|
358
|
-
*
|
|
359
|
-
* @param state State tree
|
|
360
|
-
* @param kind Entity kind.
|
|
361
|
-
* @param name Entity name.
|
|
362
|
-
* @param key Record's key
|
|
363
|
-
*
|
|
364
|
-
* @return Record.
|
|
365
|
-
*/
|
|
366
222
|
function __experimentalGetEntityRecordNoResolver(state, kind, name, key) {
|
|
367
223
|
return getEntityRecord(state, kind, name, key);
|
|
368
224
|
}
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
}
|
|
395
|
-
|
|
396
|
-
var _query$context4;
|
|
397
|
-
const context = (_query$context4 = query?.context) !== null && _query$context4 !== void 0 ? _query$context4 : 'default';
|
|
398
|
-
return [state.entities.config, state.entities.records?.[kind]?.[name]?.queriedData?.items[context]?.[recordId], state.entities.records?.[kind]?.[name]?.queriedData?.itemIsComplete[context]?.[recordId]];
|
|
399
|
-
});
|
|
400
|
-
|
|
401
|
-
/**
|
|
402
|
-
* Returns true if records have been received for the given set of parameters,
|
|
403
|
-
* or false otherwise.
|
|
404
|
-
*
|
|
405
|
-
* @param state State tree
|
|
406
|
-
* @param kind Entity kind.
|
|
407
|
-
* @param name Entity name.
|
|
408
|
-
* @param query Optional terms query. For valid query parameters see the [Reference](https://developer.wordpress.org/rest-api/reference/) in the REST API Handbook and select the entity kind. Then see the arguments available for "List [Entity kind]s".
|
|
409
|
-
*
|
|
410
|
-
* @return Whether entity records have been received.
|
|
411
|
-
*/
|
|
225
|
+
const getRawEntityRecord = (0, import_data.createSelector)(
|
|
226
|
+
(state, kind, name, key) => {
|
|
227
|
+
(0, import_log_entity_deprecation.default)(kind, name, "getRawEntityRecord");
|
|
228
|
+
const record = getEntityRecord(
|
|
229
|
+
state,
|
|
230
|
+
kind,
|
|
231
|
+
name,
|
|
232
|
+
key
|
|
233
|
+
);
|
|
234
|
+
return record && Object.keys(record).reduce((accumulator, _key) => {
|
|
235
|
+
if ((0, import_utils.isRawAttribute)(getEntityConfig(state, kind, name), _key)) {
|
|
236
|
+
accumulator[_key] = record[_key]?.raw !== void 0 ? record[_key]?.raw : record[_key];
|
|
237
|
+
} else {
|
|
238
|
+
accumulator[_key] = record[_key];
|
|
239
|
+
}
|
|
240
|
+
return accumulator;
|
|
241
|
+
}, {});
|
|
242
|
+
},
|
|
243
|
+
(state, kind, name, recordId, query) => {
|
|
244
|
+
const context = query?.context ?? "default";
|
|
245
|
+
return [
|
|
246
|
+
state.entities.config,
|
|
247
|
+
state.entities.records?.[kind]?.[name]?.queriedData?.items[context]?.[recordId],
|
|
248
|
+
state.entities.records?.[kind]?.[name]?.queriedData?.itemIsComplete[context]?.[recordId]
|
|
249
|
+
];
|
|
250
|
+
}
|
|
251
|
+
);
|
|
412
252
|
function hasEntityRecords(state, kind, name, query) {
|
|
413
|
-
(0,
|
|
253
|
+
(0, import_log_entity_deprecation.default)(kind, name, "hasEntityRecords");
|
|
414
254
|
return Array.isArray(getEntityRecords(state, kind, name, query));
|
|
415
255
|
}
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
* GetEntityRecord is declared as a *callable interface* with
|
|
419
|
-
* two signatures to work around the fact that TypeScript doesn't
|
|
420
|
-
* allow currying generic functions.
|
|
421
|
-
*
|
|
422
|
-
* @see GetEntityRecord
|
|
423
|
-
* @see https://github.com/WordPress/gutenberg/pull/41578
|
|
424
|
-
*/
|
|
425
|
-
|
|
426
|
-
/**
|
|
427
|
-
* Returns the Entity's records.
|
|
428
|
-
*
|
|
429
|
-
* @param state State tree
|
|
430
|
-
* @param kind Entity kind.
|
|
431
|
-
* @param name Entity name.
|
|
432
|
-
* @param query Optional terms query. If requesting specific
|
|
433
|
-
* fields, fields must always include the ID. For valid query parameters see the [Reference](https://developer.wordpress.org/rest-api/reference/) in the REST API Handbook and select the entity kind. Then see the arguments available for "List [Entity kind]s".
|
|
434
|
-
*
|
|
435
|
-
* @return Records.
|
|
436
|
-
*/
|
|
437
|
-
const getEntityRecords = (state, kind, name, query) => {
|
|
438
|
-
(0, _logEntityDeprecation.default)(kind, name, 'getEntityRecords');
|
|
439
|
-
|
|
440
|
-
// Queried data state is prepopulated for all known entities. If this is not
|
|
441
|
-
// assigned for the given parameters, then it is known to not exist.
|
|
256
|
+
const getEntityRecords = ((state, kind, name, query) => {
|
|
257
|
+
(0, import_log_entity_deprecation.default)(kind, name, "getEntityRecords");
|
|
442
258
|
const queriedState = state.entities.records?.[kind]?.[name]?.queriedData;
|
|
443
259
|
if (!queriedState) {
|
|
444
260
|
return null;
|
|
445
261
|
}
|
|
446
|
-
return (0,
|
|
447
|
-
};
|
|
448
|
-
|
|
449
|
-
/**
|
|
450
|
-
* Returns the Entity's total available records for a given query (ignoring pagination).
|
|
451
|
-
*
|
|
452
|
-
* @param state State tree
|
|
453
|
-
* @param kind Entity kind.
|
|
454
|
-
* @param name Entity name.
|
|
455
|
-
* @param query Optional terms query. If requesting specific
|
|
456
|
-
* fields, fields must always include the ID. For valid query parameters see the [Reference](https://developer.wordpress.org/rest-api/reference/) in the REST API Handbook and select the entity kind. Then see the arguments available for "List [Entity kind]s".
|
|
457
|
-
*
|
|
458
|
-
* @return number | null.
|
|
459
|
-
*/
|
|
460
|
-
exports.getEntityRecords = getEntityRecords;
|
|
262
|
+
return (0, import_queried_data.getQueriedItems)(queriedState, query);
|
|
263
|
+
});
|
|
461
264
|
const getEntityRecordsTotalItems = (state, kind, name, query) => {
|
|
462
|
-
(0,
|
|
463
|
-
|
|
464
|
-
// Queried data state is prepopulated for all known entities. If this is not
|
|
465
|
-
// assigned for the given parameters, then it is known to not exist.
|
|
265
|
+
(0, import_log_entity_deprecation.default)(kind, name, "getEntityRecordsTotalItems");
|
|
466
266
|
const queriedState = state.entities.records?.[kind]?.[name]?.queriedData;
|
|
467
267
|
if (!queriedState) {
|
|
468
268
|
return null;
|
|
469
269
|
}
|
|
470
|
-
return (0,
|
|
270
|
+
return (0, import_queried_data.getQueriedTotalItems)(queriedState, query);
|
|
471
271
|
};
|
|
472
|
-
|
|
473
|
-
/**
|
|
474
|
-
* Returns the number of available pages for the given query.
|
|
475
|
-
*
|
|
476
|
-
* @param state State tree
|
|
477
|
-
* @param kind Entity kind.
|
|
478
|
-
* @param name Entity name.
|
|
479
|
-
* @param query Optional terms query. If requesting specific
|
|
480
|
-
* fields, fields must always include the ID. For valid query parameters see the [Reference](https://developer.wordpress.org/rest-api/reference/) in the REST API Handbook and select the entity kind. Then see the arguments available for "List [Entity kind]s".
|
|
481
|
-
*
|
|
482
|
-
* @return number | null.
|
|
483
|
-
*/
|
|
484
|
-
exports.getEntityRecordsTotalItems = getEntityRecordsTotalItems;
|
|
485
272
|
const getEntityRecordsTotalPages = (state, kind, name, query) => {
|
|
486
|
-
(0,
|
|
487
|
-
|
|
488
|
-
// Queried data state is prepopulated for all known entities. If this is not
|
|
489
|
-
// assigned for the given parameters, then it is known to not exist.
|
|
273
|
+
(0, import_log_entity_deprecation.default)(kind, name, "getEntityRecordsTotalPages");
|
|
490
274
|
const queriedState = state.entities.records?.[kind]?.[name]?.queriedData;
|
|
491
275
|
if (!queriedState) {
|
|
492
276
|
return null;
|
|
@@ -494,533 +278,247 @@ const getEntityRecordsTotalPages = (state, kind, name, query) => {
|
|
|
494
278
|
if (query?.per_page === -1) {
|
|
495
279
|
return 1;
|
|
496
280
|
}
|
|
497
|
-
const totalItems = (0,
|
|
281
|
+
const totalItems = (0, import_queried_data.getQueriedTotalItems)(queriedState, query);
|
|
498
282
|
if (!totalItems) {
|
|
499
283
|
return totalItems;
|
|
500
284
|
}
|
|
501
|
-
// If `per_page` is not set and the query relies on the defaults of the
|
|
502
|
-
// REST endpoint, get the info from query's meta.
|
|
503
285
|
if (!query?.per_page) {
|
|
504
|
-
return (0,
|
|
286
|
+
return (0, import_queried_data.getQueriedTotalPages)(queriedState, query);
|
|
505
287
|
}
|
|
506
288
|
return Math.ceil(totalItems / query.per_page);
|
|
507
289
|
};
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
const
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
290
|
+
const __experimentalGetDirtyEntityRecords = (0, import_data.createSelector)(
|
|
291
|
+
(state) => {
|
|
292
|
+
const {
|
|
293
|
+
entities: { records }
|
|
294
|
+
} = state;
|
|
295
|
+
const dirtyRecords = [];
|
|
296
|
+
Object.keys(records).forEach((kind) => {
|
|
297
|
+
Object.keys(records[kind]).forEach((name) => {
|
|
298
|
+
const primaryKeys = Object.keys(records[kind][name].edits).filter(
|
|
299
|
+
(primaryKey) => (
|
|
300
|
+
// The entity record must exist (not be deleted),
|
|
301
|
+
// and it must have edits.
|
|
302
|
+
getEntityRecord(state, kind, name, primaryKey) && hasEditsForEntityRecord(state, kind, name, primaryKey)
|
|
303
|
+
)
|
|
304
|
+
);
|
|
305
|
+
if (primaryKeys.length) {
|
|
306
|
+
const entityConfig = getEntityConfig(state, kind, name);
|
|
307
|
+
primaryKeys.forEach((primaryKey) => {
|
|
308
|
+
const entityRecord = getEditedEntityRecord(
|
|
309
|
+
state,
|
|
310
|
+
kind,
|
|
311
|
+
name,
|
|
312
|
+
primaryKey
|
|
313
|
+
);
|
|
314
|
+
dirtyRecords.push({
|
|
315
|
+
// We avoid using primaryKey because it's transformed into a string
|
|
316
|
+
// when it's used as an object key.
|
|
317
|
+
key: entityRecord ? entityRecord[entityConfig.key || import_entities.DEFAULT_ENTITY_KEY] : void 0,
|
|
318
|
+
title: entityConfig?.getTitle?.(entityRecord) || "",
|
|
319
|
+
name,
|
|
320
|
+
kind
|
|
321
|
+
});
|
|
540
322
|
});
|
|
541
|
-
}
|
|
542
|
-
}
|
|
323
|
+
}
|
|
324
|
+
});
|
|
543
325
|
});
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
326
|
+
return dirtyRecords;
|
|
327
|
+
},
|
|
328
|
+
(state) => [state.entities.records]
|
|
329
|
+
);
|
|
330
|
+
const __experimentalGetEntitiesBeingSaved = (0, import_data.createSelector)(
|
|
331
|
+
(state) => {
|
|
332
|
+
const {
|
|
333
|
+
entities: { records }
|
|
334
|
+
} = state;
|
|
335
|
+
const recordsBeingSaved = [];
|
|
336
|
+
Object.keys(records).forEach((kind) => {
|
|
337
|
+
Object.keys(records[kind]).forEach((name) => {
|
|
338
|
+
const primaryKeys = Object.keys(records[kind][name].saving).filter(
|
|
339
|
+
(primaryKey) => isSavingEntityRecord(state, kind, name, primaryKey)
|
|
340
|
+
);
|
|
341
|
+
if (primaryKeys.length) {
|
|
342
|
+
const entityConfig = getEntityConfig(state, kind, name);
|
|
343
|
+
primaryKeys.forEach((primaryKey) => {
|
|
344
|
+
const entityRecord = getEditedEntityRecord(
|
|
345
|
+
state,
|
|
346
|
+
kind,
|
|
347
|
+
name,
|
|
348
|
+
primaryKey
|
|
349
|
+
);
|
|
350
|
+
recordsBeingSaved.push({
|
|
351
|
+
// We avoid using primaryKey because it's transformed into a string
|
|
352
|
+
// when it's used as an object key.
|
|
353
|
+
key: entityRecord ? entityRecord[entityConfig.key || import_entities.DEFAULT_ENTITY_KEY] : void 0,
|
|
354
|
+
title: entityConfig?.getTitle?.(entityRecord) || "",
|
|
355
|
+
name,
|
|
356
|
+
kind
|
|
357
|
+
});
|
|
576
358
|
});
|
|
577
|
-
}
|
|
578
|
-
}
|
|
359
|
+
}
|
|
360
|
+
});
|
|
579
361
|
});
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
/**
|
|
585
|
-
* Returns the specified entity record's edits.
|
|
586
|
-
*
|
|
587
|
-
* @param state State tree.
|
|
588
|
-
* @param kind Entity kind.
|
|
589
|
-
* @param name Entity name.
|
|
590
|
-
* @param recordId Record ID.
|
|
591
|
-
*
|
|
592
|
-
* @return The entity record's edits.
|
|
593
|
-
*/
|
|
362
|
+
return recordsBeingSaved;
|
|
363
|
+
},
|
|
364
|
+
(state) => [state.entities.records]
|
|
365
|
+
);
|
|
594
366
|
function getEntityRecordEdits(state, kind, name, recordId) {
|
|
595
|
-
(0,
|
|
367
|
+
(0, import_log_entity_deprecation.default)(kind, name, "getEntityRecordEdits");
|
|
596
368
|
return state.entities.records?.[kind]?.[name]?.edits?.[recordId];
|
|
597
369
|
}
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
*
|
|
606
|
-
* @param state State tree.
|
|
607
|
-
* @param kind Entity kind.
|
|
608
|
-
* @param name Entity name.
|
|
609
|
-
* @param recordId Record ID.
|
|
610
|
-
*
|
|
611
|
-
* @return The entity record's non transient edits.
|
|
612
|
-
*/
|
|
613
|
-
const getEntityRecordNonTransientEdits = exports.getEntityRecordNonTransientEdits = (0, _data.createSelector)((state, kind, name, recordId) => {
|
|
614
|
-
(0, _logEntityDeprecation.default)(kind, name, 'getEntityRecordNonTransientEdits');
|
|
615
|
-
const {
|
|
616
|
-
transientEdits
|
|
617
|
-
} = getEntityConfig(state, kind, name) || {};
|
|
618
|
-
const edits = getEntityRecordEdits(state, kind, name, recordId) || {};
|
|
619
|
-
if (!transientEdits) {
|
|
620
|
-
return edits;
|
|
621
|
-
}
|
|
622
|
-
return Object.keys(edits).reduce((acc, key) => {
|
|
623
|
-
if (!transientEdits[key]) {
|
|
624
|
-
acc[key] = edits[key];
|
|
370
|
+
const getEntityRecordNonTransientEdits = (0, import_data.createSelector)(
|
|
371
|
+
(state, kind, name, recordId) => {
|
|
372
|
+
(0, import_log_entity_deprecation.default)(kind, name, "getEntityRecordNonTransientEdits");
|
|
373
|
+
const { transientEdits } = getEntityConfig(state, kind, name) || {};
|
|
374
|
+
const edits = getEntityRecordEdits(state, kind, name, recordId) || {};
|
|
375
|
+
if (!transientEdits) {
|
|
376
|
+
return edits;
|
|
625
377
|
}
|
|
626
|
-
return acc
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
*
|
|
639
|
-
* @return Whether the entity record has edits or not.
|
|
640
|
-
*/
|
|
378
|
+
return Object.keys(edits).reduce((acc, key) => {
|
|
379
|
+
if (!transientEdits[key]) {
|
|
380
|
+
acc[key] = edits[key];
|
|
381
|
+
}
|
|
382
|
+
return acc;
|
|
383
|
+
}, {});
|
|
384
|
+
},
|
|
385
|
+
(state, kind, name, recordId) => [
|
|
386
|
+
state.entities.config,
|
|
387
|
+
state.entities.records?.[kind]?.[name]?.edits?.[recordId]
|
|
388
|
+
]
|
|
389
|
+
);
|
|
641
390
|
function hasEditsForEntityRecord(state, kind, name, recordId) {
|
|
642
|
-
(0,
|
|
643
|
-
return isSavingEntityRecord(state, kind, name, recordId) || Object.keys(
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
391
|
+
(0, import_log_entity_deprecation.default)(kind, name, "hasEditsForEntityRecord");
|
|
392
|
+
return isSavingEntityRecord(state, kind, name, recordId) || Object.keys(
|
|
393
|
+
getEntityRecordNonTransientEdits(state, kind, name, recordId)
|
|
394
|
+
).length > 0;
|
|
395
|
+
}
|
|
396
|
+
const getEditedEntityRecord = (0, import_data.createSelector)(
|
|
397
|
+
(state, kind, name, recordId) => {
|
|
398
|
+
(0, import_log_entity_deprecation.default)(kind, name, "getEditedEntityRecord");
|
|
399
|
+
const raw = getRawEntityRecord(state, kind, name, recordId);
|
|
400
|
+
const edited = getEntityRecordEdits(state, kind, name, recordId);
|
|
401
|
+
if (!raw && !edited) {
|
|
402
|
+
return false;
|
|
403
|
+
}
|
|
404
|
+
return {
|
|
405
|
+
...raw,
|
|
406
|
+
...edited
|
|
407
|
+
};
|
|
408
|
+
},
|
|
409
|
+
(state, kind, name, recordId, query) => {
|
|
410
|
+
const context = query?.context ?? "default";
|
|
411
|
+
return [
|
|
412
|
+
state.entities.config,
|
|
413
|
+
state.entities.records?.[kind]?.[name]?.queriedData.items[context]?.[recordId],
|
|
414
|
+
state.entities.records?.[kind]?.[name]?.queriedData.itemIsComplete[context]?.[recordId],
|
|
415
|
+
state.entities.records?.[kind]?.[name]?.edits?.[recordId]
|
|
416
|
+
];
|
|
666
417
|
}
|
|
667
|
-
|
|
668
|
-
...raw,
|
|
669
|
-
...edited
|
|
670
|
-
};
|
|
671
|
-
}, (state, kind, name, recordId, query) => {
|
|
672
|
-
var _query$context5;
|
|
673
|
-
const context = (_query$context5 = query?.context) !== null && _query$context5 !== void 0 ? _query$context5 : 'default';
|
|
674
|
-
return [state.entities.config, state.entities.records?.[kind]?.[name]?.queriedData.items[context]?.[recordId], state.entities.records?.[kind]?.[name]?.queriedData.itemIsComplete[context]?.[recordId], state.entities.records?.[kind]?.[name]?.edits?.[recordId]];
|
|
675
|
-
});
|
|
676
|
-
|
|
677
|
-
/**
|
|
678
|
-
* Returns true if the specified entity record is autosaving, and false otherwise.
|
|
679
|
-
*
|
|
680
|
-
* @param state State tree.
|
|
681
|
-
* @param kind Entity kind.
|
|
682
|
-
* @param name Entity name.
|
|
683
|
-
* @param recordId Record ID.
|
|
684
|
-
*
|
|
685
|
-
* @return Whether the entity record is autosaving or not.
|
|
686
|
-
*/
|
|
418
|
+
);
|
|
687
419
|
function isAutosavingEntityRecord(state, kind, name, recordId) {
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
const {
|
|
691
|
-
pending,
|
|
692
|
-
isAutosave
|
|
693
|
-
} = (_state$entities$recor = state.entities.records?.[kind]?.[name]?.saving?.[recordId]) !== null && _state$entities$recor !== void 0 ? _state$entities$recor : {};
|
|
420
|
+
(0, import_log_entity_deprecation.default)(kind, name, "isAutosavingEntityRecord");
|
|
421
|
+
const { pending, isAutosave } = state.entities.records?.[kind]?.[name]?.saving?.[recordId] ?? {};
|
|
694
422
|
return Boolean(pending && isAutosave);
|
|
695
423
|
}
|
|
696
|
-
|
|
697
|
-
/**
|
|
698
|
-
* Returns true if the specified entity record is saving, and false otherwise.
|
|
699
|
-
*
|
|
700
|
-
* @param state State tree.
|
|
701
|
-
* @param kind Entity kind.
|
|
702
|
-
* @param name Entity name.
|
|
703
|
-
* @param recordId Record ID.
|
|
704
|
-
*
|
|
705
|
-
* @return Whether the entity record is saving or not.
|
|
706
|
-
*/
|
|
707
424
|
function isSavingEntityRecord(state, kind, name, recordId) {
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
return (_state$entities$recor2 = state.entities.records?.[kind]?.[name]?.saving?.[recordId]?.pending) !== null && _state$entities$recor2 !== void 0 ? _state$entities$recor2 : false;
|
|
425
|
+
(0, import_log_entity_deprecation.default)(kind, name, "isSavingEntityRecord");
|
|
426
|
+
return state.entities.records?.[kind]?.[name]?.saving?.[recordId]?.pending ?? false;
|
|
711
427
|
}
|
|
712
|
-
|
|
713
|
-
/**
|
|
714
|
-
* Returns true if the specified entity record is deleting, and false otherwise.
|
|
715
|
-
*
|
|
716
|
-
* @param state State tree.
|
|
717
|
-
* @param kind Entity kind.
|
|
718
|
-
* @param name Entity name.
|
|
719
|
-
* @param recordId Record ID.
|
|
720
|
-
*
|
|
721
|
-
* @return Whether the entity record is deleting or not.
|
|
722
|
-
*/
|
|
723
428
|
function isDeletingEntityRecord(state, kind, name, recordId) {
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
return (_state$entities$recor3 = state.entities.records?.[kind]?.[name]?.deleting?.[recordId]?.pending) !== null && _state$entities$recor3 !== void 0 ? _state$entities$recor3 : false;
|
|
429
|
+
(0, import_log_entity_deprecation.default)(kind, name, "isDeletingEntityRecord");
|
|
430
|
+
return state.entities.records?.[kind]?.[name]?.deleting?.[recordId]?.pending ?? false;
|
|
727
431
|
}
|
|
728
|
-
|
|
729
|
-
/**
|
|
730
|
-
* Returns the specified entity record's last save error.
|
|
731
|
-
*
|
|
732
|
-
* @param state State tree.
|
|
733
|
-
* @param kind Entity kind.
|
|
734
|
-
* @param name Entity name.
|
|
735
|
-
* @param recordId Record ID.
|
|
736
|
-
*
|
|
737
|
-
* @return The entity record's save error.
|
|
738
|
-
*/
|
|
739
432
|
function getLastEntitySaveError(state, kind, name, recordId) {
|
|
740
|
-
(0,
|
|
433
|
+
(0, import_log_entity_deprecation.default)(kind, name, "getLastEntitySaveError");
|
|
741
434
|
return state.entities.records?.[kind]?.[name]?.saving?.[recordId]?.error;
|
|
742
435
|
}
|
|
743
|
-
|
|
744
|
-
/**
|
|
745
|
-
* Returns the specified entity record's last delete error.
|
|
746
|
-
*
|
|
747
|
-
* @param state State tree.
|
|
748
|
-
* @param kind Entity kind.
|
|
749
|
-
* @param name Entity name.
|
|
750
|
-
* @param recordId Record ID.
|
|
751
|
-
*
|
|
752
|
-
* @return The entity record's save error.
|
|
753
|
-
*/
|
|
754
436
|
function getLastEntityDeleteError(state, kind, name, recordId) {
|
|
755
|
-
(0,
|
|
437
|
+
(0, import_log_entity_deprecation.default)(kind, name, "getLastEntityDeleteError");
|
|
756
438
|
return state.entities.records?.[kind]?.[name]?.deleting?.[recordId]?.error;
|
|
757
439
|
}
|
|
758
|
-
|
|
759
|
-
/* eslint-disable @typescript-eslint/no-unused-vars */
|
|
760
|
-
/**
|
|
761
|
-
* Returns the previous edit from the current undo offset
|
|
762
|
-
* for the entity records edits history, if any.
|
|
763
|
-
*
|
|
764
|
-
* @deprecated since 6.3
|
|
765
|
-
*
|
|
766
|
-
* @param state State tree.
|
|
767
|
-
*
|
|
768
|
-
* @return The edit.
|
|
769
|
-
*/
|
|
770
440
|
function getUndoEdit(state) {
|
|
771
|
-
(0,
|
|
772
|
-
since:
|
|
441
|
+
(0, import_deprecated.default)("select( 'core' ).getUndoEdit()", {
|
|
442
|
+
since: "6.3"
|
|
773
443
|
});
|
|
774
|
-
return
|
|
444
|
+
return void 0;
|
|
775
445
|
}
|
|
776
|
-
/* eslint-enable @typescript-eslint/no-unused-vars */
|
|
777
|
-
|
|
778
|
-
/* eslint-disable @typescript-eslint/no-unused-vars */
|
|
779
|
-
/**
|
|
780
|
-
* Returns the next edit from the current undo offset
|
|
781
|
-
* for the entity records edits history, if any.
|
|
782
|
-
*
|
|
783
|
-
* @deprecated since 6.3
|
|
784
|
-
*
|
|
785
|
-
* @param state State tree.
|
|
786
|
-
*
|
|
787
|
-
* @return The edit.
|
|
788
|
-
*/
|
|
789
446
|
function getRedoEdit(state) {
|
|
790
|
-
(0,
|
|
791
|
-
since:
|
|
447
|
+
(0, import_deprecated.default)("select( 'core' ).getRedoEdit()", {
|
|
448
|
+
since: "6.3"
|
|
792
449
|
});
|
|
793
|
-
return
|
|
450
|
+
return void 0;
|
|
794
451
|
}
|
|
795
|
-
/* eslint-enable @typescript-eslint/no-unused-vars */
|
|
796
|
-
|
|
797
|
-
/**
|
|
798
|
-
* Returns true if there is a previous edit from the current undo offset
|
|
799
|
-
* for the entity records edits history, and false otherwise.
|
|
800
|
-
*
|
|
801
|
-
* @param state State tree.
|
|
802
|
-
*
|
|
803
|
-
* @return Whether there is a previous edit or not.
|
|
804
|
-
*/
|
|
805
452
|
function hasUndo(state) {
|
|
806
453
|
return state.undoManager.hasUndo();
|
|
807
454
|
}
|
|
808
|
-
|
|
809
|
-
/**
|
|
810
|
-
* Returns true if there is a next edit from the current undo offset
|
|
811
|
-
* for the entity records edits history, and false otherwise.
|
|
812
|
-
*
|
|
813
|
-
* @param state State tree.
|
|
814
|
-
*
|
|
815
|
-
* @return Whether there is a next edit or not.
|
|
816
|
-
*/
|
|
817
455
|
function hasRedo(state) {
|
|
818
456
|
return state.undoManager.hasRedo();
|
|
819
457
|
}
|
|
820
|
-
|
|
821
|
-
/**
|
|
822
|
-
* Return the current theme.
|
|
823
|
-
*
|
|
824
|
-
* @param state Data state.
|
|
825
|
-
*
|
|
826
|
-
* @return The current theme.
|
|
827
|
-
*/
|
|
828
458
|
function getCurrentTheme(state) {
|
|
829
459
|
if (!state.currentTheme) {
|
|
830
460
|
return null;
|
|
831
461
|
}
|
|
832
|
-
return getEntityRecord(state,
|
|
462
|
+
return getEntityRecord(state, "root", "theme", state.currentTheme);
|
|
833
463
|
}
|
|
834
|
-
|
|
835
|
-
/**
|
|
836
|
-
* Return the ID of the current global styles object.
|
|
837
|
-
*
|
|
838
|
-
* @param state Data state.
|
|
839
|
-
*
|
|
840
|
-
* @return The current global styles ID.
|
|
841
|
-
*/
|
|
842
464
|
function __experimentalGetCurrentGlobalStylesId(state) {
|
|
843
465
|
return state.currentGlobalStylesId;
|
|
844
466
|
}
|
|
845
|
-
|
|
846
|
-
/**
|
|
847
|
-
* Return theme supports data in the index.
|
|
848
|
-
*
|
|
849
|
-
* @param state Data state.
|
|
850
|
-
*
|
|
851
|
-
* @return Index data.
|
|
852
|
-
*/
|
|
853
467
|
function getThemeSupports(state) {
|
|
854
|
-
|
|
855
|
-
return (_getCurrentTheme$them = getCurrentTheme(state)?.theme_supports) !== null && _getCurrentTheme$them !== void 0 ? _getCurrentTheme$them : EMPTY_OBJECT;
|
|
468
|
+
return getCurrentTheme(state)?.theme_supports ?? EMPTY_OBJECT;
|
|
856
469
|
}
|
|
857
|
-
|
|
858
|
-
/**
|
|
859
|
-
* Returns the embed preview for the given URL.
|
|
860
|
-
*
|
|
861
|
-
* @param state Data state.
|
|
862
|
-
* @param url Embedded URL.
|
|
863
|
-
*
|
|
864
|
-
* @return Undefined if the preview has not been fetched, otherwise, the preview fetched from the embed preview API.
|
|
865
|
-
*/
|
|
866
470
|
function getEmbedPreview(state, url) {
|
|
867
471
|
return state.embedPreviews[url];
|
|
868
472
|
}
|
|
869
|
-
|
|
870
|
-
/**
|
|
871
|
-
* Determines if the returned preview is an oEmbed link fallback.
|
|
872
|
-
*
|
|
873
|
-
* WordPress can be configured to return a simple link to a URL if it is not embeddable.
|
|
874
|
-
* We need to be able to determine if a URL is embeddable or not, based on what we
|
|
875
|
-
* get back from the oEmbed preview API.
|
|
876
|
-
*
|
|
877
|
-
* @param state Data state.
|
|
878
|
-
* @param url Embedded URL.
|
|
879
|
-
*
|
|
880
|
-
* @return Is the preview for the URL an oEmbed link fallback.
|
|
881
|
-
*/
|
|
882
473
|
function isPreviewEmbedFallback(state, url) {
|
|
883
474
|
const preview = state.embedPreviews[url];
|
|
884
|
-
const oEmbedLinkCheck = '<a href="' + url + '">' + url +
|
|
475
|
+
const oEmbedLinkCheck = '<a href="' + url + '">' + url + "</a>";
|
|
885
476
|
if (!preview) {
|
|
886
477
|
return false;
|
|
887
478
|
}
|
|
888
479
|
return preview.html === oEmbedLinkCheck;
|
|
889
480
|
}
|
|
890
|
-
|
|
891
|
-
/**
|
|
892
|
-
* Returns whether the current user can perform the given action on the given
|
|
893
|
-
* REST resource.
|
|
894
|
-
*
|
|
895
|
-
* Calling this may trigger an OPTIONS request to the REST API via the
|
|
896
|
-
* `canUser()` resolver.
|
|
897
|
-
*
|
|
898
|
-
* https://developer.wordpress.org/rest-api/reference/
|
|
899
|
-
*
|
|
900
|
-
* @param state Data state.
|
|
901
|
-
* @param action Action to check. One of: 'create', 'read', 'update', 'delete'.
|
|
902
|
-
* @param resource Entity resource to check. Accepts entity object `{ kind: 'postType', name: 'attachment', id: 1 }`
|
|
903
|
-
* or REST base as a string - `media`.
|
|
904
|
-
* @param id Optional ID of the rest resource to check.
|
|
905
|
-
*
|
|
906
|
-
* @return Whether or not the user can perform the action,
|
|
907
|
-
* or `undefined` if the OPTIONS request is still being made.
|
|
908
|
-
*/
|
|
909
481
|
function canUser(state, action, resource, id) {
|
|
910
|
-
const isEntity = typeof resource ===
|
|
482
|
+
const isEntity = typeof resource === "object";
|
|
911
483
|
if (isEntity && (!resource.kind || !resource.name)) {
|
|
912
484
|
return false;
|
|
913
485
|
}
|
|
914
486
|
if (isEntity) {
|
|
915
|
-
(0,
|
|
487
|
+
(0, import_log_entity_deprecation.default)(resource.kind, resource.name, "canUser");
|
|
916
488
|
}
|
|
917
|
-
const key = (0,
|
|
489
|
+
const key = (0, import_utils.getUserPermissionCacheKey)(action, resource, id);
|
|
918
490
|
return state.userPermissions[key];
|
|
919
491
|
}
|
|
920
|
-
|
|
921
|
-
/**
|
|
922
|
-
* Returns whether the current user can edit the given entity.
|
|
923
|
-
*
|
|
924
|
-
* Calling this may trigger an OPTIONS request to the REST API via the
|
|
925
|
-
* `canUser()` resolver.
|
|
926
|
-
*
|
|
927
|
-
* https://developer.wordpress.org/rest-api/reference/
|
|
928
|
-
*
|
|
929
|
-
* @param state Data state.
|
|
930
|
-
* @param kind Entity kind.
|
|
931
|
-
* @param name Entity name.
|
|
932
|
-
* @param recordId Record's id.
|
|
933
|
-
* @return Whether or not the user can edit,
|
|
934
|
-
* or `undefined` if the OPTIONS request is still being made.
|
|
935
|
-
*/
|
|
936
492
|
function canUserEditEntityRecord(state, kind, name, recordId) {
|
|
937
|
-
(0,
|
|
938
|
-
since:
|
|
493
|
+
(0, import_deprecated.default)(`wp.data.select( 'core' ).canUserEditEntityRecord()`, {
|
|
494
|
+
since: "6.7",
|
|
939
495
|
alternative: `wp.data.select( 'core' ).canUser( 'update', { kind, name, id } )`
|
|
940
496
|
});
|
|
941
|
-
return canUser(state,
|
|
942
|
-
kind,
|
|
943
|
-
name,
|
|
944
|
-
id: recordId
|
|
945
|
-
});
|
|
497
|
+
return canUser(state, "update", { kind, name, id: recordId });
|
|
946
498
|
}
|
|
947
|
-
|
|
948
|
-
/**
|
|
949
|
-
* Returns the latest autosaves for the post.
|
|
950
|
-
*
|
|
951
|
-
* May return multiple autosaves since the backend stores one autosave per
|
|
952
|
-
* author for each post.
|
|
953
|
-
*
|
|
954
|
-
* @param state State tree.
|
|
955
|
-
* @param postType The type of the parent post.
|
|
956
|
-
* @param postId The id of the parent post.
|
|
957
|
-
*
|
|
958
|
-
* @return An array of autosaves for the post, or undefined if there is none.
|
|
959
|
-
*/
|
|
960
499
|
function getAutosaves(state, postType, postId) {
|
|
961
500
|
return state.autosaves[postId];
|
|
962
501
|
}
|
|
963
|
-
|
|
964
|
-
/**
|
|
965
|
-
* Returns the autosave for the post and author.
|
|
966
|
-
*
|
|
967
|
-
* @param state State tree.
|
|
968
|
-
* @param postType The type of the parent post.
|
|
969
|
-
* @param postId The id of the parent post.
|
|
970
|
-
* @param authorId The id of the author.
|
|
971
|
-
*
|
|
972
|
-
* @return The autosave for the post and author.
|
|
973
|
-
*/
|
|
974
502
|
function getAutosave(state, postType, postId, authorId) {
|
|
975
|
-
if (authorId ===
|
|
503
|
+
if (authorId === void 0) {
|
|
976
504
|
return;
|
|
977
505
|
}
|
|
978
506
|
const autosaves = state.autosaves[postId];
|
|
979
|
-
return autosaves?.find(
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
const hasFetchedAutosaves = exports.hasFetchedAutosaves = (0, _data.createRegistrySelector)(select => (state, postType, postId) => {
|
|
992
|
-
return select(_name.STORE_NAME).hasFinishedResolution('getAutosaves', [postType, postId]);
|
|
993
|
-
});
|
|
994
|
-
|
|
995
|
-
/**
|
|
996
|
-
* Returns a new reference when edited values have changed. This is useful in
|
|
997
|
-
* inferring where an edit has been made between states by comparison of the
|
|
998
|
-
* return values using strict equality.
|
|
999
|
-
*
|
|
1000
|
-
* @example
|
|
1001
|
-
*
|
|
1002
|
-
* ```
|
|
1003
|
-
* const hasEditOccurred = (
|
|
1004
|
-
* getReferenceByDistinctEdits( beforeState ) !==
|
|
1005
|
-
* getReferenceByDistinctEdits( afterState )
|
|
1006
|
-
* );
|
|
1007
|
-
* ```
|
|
1008
|
-
*
|
|
1009
|
-
* @param state Editor state.
|
|
1010
|
-
*
|
|
1011
|
-
* @return A value whose reference will change only when an edit occurs.
|
|
1012
|
-
*/
|
|
507
|
+
return autosaves?.find(
|
|
508
|
+
(autosave) => autosave.author === authorId
|
|
509
|
+
);
|
|
510
|
+
}
|
|
511
|
+
const hasFetchedAutosaves = (0, import_data.createRegistrySelector)(
|
|
512
|
+
(select) => (state, postType, postId) => {
|
|
513
|
+
return select(import_name.STORE_NAME).hasFinishedResolution("getAutosaves", [
|
|
514
|
+
postType,
|
|
515
|
+
postId
|
|
516
|
+
]);
|
|
517
|
+
}
|
|
518
|
+
);
|
|
1013
519
|
function getReferenceByDistinctEdits(state) {
|
|
1014
520
|
return state.editsReference;
|
|
1015
521
|
}
|
|
1016
|
-
|
|
1017
|
-
/**
|
|
1018
|
-
* Retrieve the current theme's base global styles
|
|
1019
|
-
*
|
|
1020
|
-
* @param state Editor state.
|
|
1021
|
-
*
|
|
1022
|
-
* @return The Global Styles object.
|
|
1023
|
-
*/
|
|
1024
522
|
function __experimentalGetCurrentThemeBaseGlobalStyles(state) {
|
|
1025
523
|
const currentTheme = getCurrentTheme(state);
|
|
1026
524
|
if (!currentTheme) {
|
|
@@ -1028,14 +526,6 @@ function __experimentalGetCurrentThemeBaseGlobalStyles(state) {
|
|
|
1028
526
|
}
|
|
1029
527
|
return state.themeBaseGlobalStyles[currentTheme.stylesheet];
|
|
1030
528
|
}
|
|
1031
|
-
|
|
1032
|
-
/**
|
|
1033
|
-
* Return the ID of the current global styles object.
|
|
1034
|
-
*
|
|
1035
|
-
* @param state Data state.
|
|
1036
|
-
*
|
|
1037
|
-
* @return The current global styles ID.
|
|
1038
|
-
*/
|
|
1039
529
|
function __experimentalGetCurrentThemeGlobalStylesVariations(state) {
|
|
1040
530
|
const currentTheme = getCurrentTheme(state);
|
|
1041
531
|
if (!currentTheme) {
|
|
@@ -1043,53 +533,18 @@ function __experimentalGetCurrentThemeGlobalStylesVariations(state) {
|
|
|
1043
533
|
}
|
|
1044
534
|
return state.themeGlobalStyleVariations[currentTheme.stylesheet];
|
|
1045
535
|
}
|
|
1046
|
-
|
|
1047
|
-
/**
|
|
1048
|
-
* Retrieve the list of registered block patterns.
|
|
1049
|
-
*
|
|
1050
|
-
* @param state Data state.
|
|
1051
|
-
*
|
|
1052
|
-
* @return Block pattern list.
|
|
1053
|
-
*/
|
|
1054
536
|
function getBlockPatterns(state) {
|
|
1055
537
|
return state.blockPatterns;
|
|
1056
538
|
}
|
|
1057
|
-
|
|
1058
|
-
/**
|
|
1059
|
-
* Retrieve the list of registered block pattern categories.
|
|
1060
|
-
*
|
|
1061
|
-
* @param state Data state.
|
|
1062
|
-
*
|
|
1063
|
-
* @return Block pattern category list.
|
|
1064
|
-
*/
|
|
1065
539
|
function getBlockPatternCategories(state) {
|
|
1066
540
|
return state.blockPatternCategories;
|
|
1067
541
|
}
|
|
1068
|
-
|
|
1069
|
-
/**
|
|
1070
|
-
* Retrieve the registered user pattern categories.
|
|
1071
|
-
*
|
|
1072
|
-
* @param state Data state.
|
|
1073
|
-
*
|
|
1074
|
-
* @return User patterns category array.
|
|
1075
|
-
*/
|
|
1076
|
-
|
|
1077
542
|
function getUserPatternCategories(state) {
|
|
1078
543
|
return state.userPatternCategories;
|
|
1079
544
|
}
|
|
1080
|
-
|
|
1081
|
-
/**
|
|
1082
|
-
* Returns the revisions of the current global styles theme.
|
|
1083
|
-
*
|
|
1084
|
-
* @deprecated since WordPress 6.5.0. Callers should use `select( 'core' ).getRevisions( 'root', 'globalStyles', ${ recordKey } )` instead, where `recordKey` is the id of the global styles parent post.
|
|
1085
|
-
*
|
|
1086
|
-
* @param state Data state.
|
|
1087
|
-
*
|
|
1088
|
-
* @return The current global styles.
|
|
1089
|
-
*/
|
|
1090
545
|
function getCurrentThemeGlobalStylesRevisions(state) {
|
|
1091
|
-
(0,
|
|
1092
|
-
since:
|
|
546
|
+
(0, import_deprecated.default)("select( 'core' ).getCurrentThemeGlobalStylesRevisions()", {
|
|
547
|
+
since: "6.5.0",
|
|
1093
548
|
alternative: "select( 'core' ).getRevisions( 'root', 'globalStyles', ${ recordKey } )"
|
|
1094
549
|
});
|
|
1095
550
|
const currentGlobalStylesId = __experimentalGetCurrentGlobalStylesId(state);
|
|
@@ -1098,88 +553,108 @@ function getCurrentThemeGlobalStylesRevisions(state) {
|
|
|
1098
553
|
}
|
|
1099
554
|
return state.themeGlobalStyleRevisions[currentGlobalStylesId];
|
|
1100
555
|
}
|
|
1101
|
-
|
|
1102
|
-
/**
|
|
1103
|
-
* Returns the default template use to render a given query.
|
|
1104
|
-
*
|
|
1105
|
-
* @param state Data state.
|
|
1106
|
-
* @param query Query.
|
|
1107
|
-
*
|
|
1108
|
-
* @return The default template id for the given query.
|
|
1109
|
-
*/
|
|
1110
556
|
function getDefaultTemplateId(state, query) {
|
|
1111
557
|
return state.defaultTemplates[JSON.stringify(query)];
|
|
1112
558
|
}
|
|
1113
|
-
|
|
1114
|
-
/**
|
|
1115
|
-
* Returns an entity's revisions.
|
|
1116
|
-
*
|
|
1117
|
-
* @param state State tree
|
|
1118
|
-
* @param kind Entity kind.
|
|
1119
|
-
* @param name Entity name.
|
|
1120
|
-
* @param recordKey The key of the entity record whose revisions you want to fetch.
|
|
1121
|
-
* @param query Optional query. If requesting specific
|
|
1122
|
-
* fields, fields must always include the ID. For valid query parameters see revisions schema in [the REST API Handbook](https://developer.wordpress.org/rest-api/reference/). Then see the arguments available "Retrieve a [Entity kind]".
|
|
1123
|
-
*
|
|
1124
|
-
* @return Record.
|
|
1125
|
-
*/
|
|
1126
559
|
const getRevisions = (state, kind, name, recordKey, query) => {
|
|
1127
|
-
(0,
|
|
560
|
+
(0, import_log_entity_deprecation.default)(kind, name, "getRevisions");
|
|
1128
561
|
const queriedStateRevisions = state.entities.records?.[kind]?.[name]?.revisions?.[recordKey];
|
|
1129
562
|
if (!queriedStateRevisions) {
|
|
1130
563
|
return null;
|
|
1131
564
|
}
|
|
1132
|
-
return (0,
|
|
565
|
+
return (0, import_queried_data.getQueriedItems)(queriedStateRevisions, query);
|
|
1133
566
|
};
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
* @param name Entity name.
|
|
1141
|
-
* @param recordKey The key of the entity record whose revisions you want to fetch.
|
|
1142
|
-
* @param revisionKey The revision's key.
|
|
1143
|
-
* @param query Optional query. If requesting specific
|
|
1144
|
-
* fields, fields must always include the ID. For valid query parameters see revisions schema in [the REST API Handbook](https://developer.wordpress.org/rest-api/reference/). Then see the arguments available "Retrieve a [entity kind]".
|
|
1145
|
-
*
|
|
1146
|
-
* @return Record.
|
|
1147
|
-
*/
|
|
1148
|
-
exports.getRevisions = getRevisions;
|
|
1149
|
-
const getRevision = exports.getRevision = (0, _data.createSelector)((state, kind, name, recordKey, revisionKey, query) => {
|
|
1150
|
-
var _query$context6, _getNormalizedCommaSe3;
|
|
1151
|
-
(0, _logEntityDeprecation.default)(kind, name, 'getRevision');
|
|
1152
|
-
const queriedState = state.entities.records?.[kind]?.[name]?.revisions?.[recordKey];
|
|
1153
|
-
if (!queriedState) {
|
|
1154
|
-
return undefined;
|
|
1155
|
-
}
|
|
1156
|
-
const context = (_query$context6 = query?.context) !== null && _query$context6 !== void 0 ? _query$context6 : 'default';
|
|
1157
|
-
if (!query || !query._fields) {
|
|
1158
|
-
// If expecting a complete item, validate that completeness.
|
|
1159
|
-
if (!queriedState.itemIsComplete[context]?.[revisionKey]) {
|
|
1160
|
-
return undefined;
|
|
567
|
+
const getRevision = (0, import_data.createSelector)(
|
|
568
|
+
(state, kind, name, recordKey, revisionKey, query) => {
|
|
569
|
+
(0, import_log_entity_deprecation.default)(kind, name, "getRevision");
|
|
570
|
+
const queriedState = state.entities.records?.[kind]?.[name]?.revisions?.[recordKey];
|
|
571
|
+
if (!queriedState) {
|
|
572
|
+
return void 0;
|
|
1161
573
|
}
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
574
|
+
const context = query?.context ?? "default";
|
|
575
|
+
if (!query || !query._fields) {
|
|
576
|
+
if (!queriedState.itemIsComplete[context]?.[revisionKey]) {
|
|
577
|
+
return void 0;
|
|
578
|
+
}
|
|
579
|
+
return queriedState.items[context][revisionKey];
|
|
580
|
+
}
|
|
581
|
+
const item = queriedState.items[context]?.[revisionKey];
|
|
582
|
+
if (!item) {
|
|
583
|
+
return item;
|
|
584
|
+
}
|
|
585
|
+
const filteredItem = {};
|
|
586
|
+
const fields = (0, import_utils.getNormalizedCommaSeparable)(query._fields) ?? [];
|
|
587
|
+
for (let f = 0; f < fields.length; f++) {
|
|
588
|
+
const field = fields[f].split(".");
|
|
589
|
+
let value = item;
|
|
590
|
+
field.forEach((fieldName) => {
|
|
591
|
+
value = value?.[fieldName];
|
|
592
|
+
});
|
|
593
|
+
(0, import_utils.setNestedValue)(filteredItem, field, value);
|
|
594
|
+
}
|
|
595
|
+
return filteredItem;
|
|
596
|
+
},
|
|
597
|
+
(state, kind, name, recordKey, revisionKey, query) => {
|
|
598
|
+
const context = query?.context ?? "default";
|
|
599
|
+
const queriedState = state.entities.records?.[kind]?.[name]?.revisions?.[recordKey];
|
|
600
|
+
return [
|
|
601
|
+
queriedState?.items?.[context]?.[revisionKey],
|
|
602
|
+
queriedState?.itemIsComplete?.[context]?.[revisionKey]
|
|
603
|
+
];
|
|
1177
604
|
}
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
|
|
605
|
+
);
|
|
606
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
607
|
+
0 && (module.exports = {
|
|
608
|
+
__experimentalGetCurrentGlobalStylesId,
|
|
609
|
+
__experimentalGetCurrentThemeBaseGlobalStyles,
|
|
610
|
+
__experimentalGetCurrentThemeGlobalStylesVariations,
|
|
611
|
+
__experimentalGetDirtyEntityRecords,
|
|
612
|
+
__experimentalGetEntitiesBeingSaved,
|
|
613
|
+
__experimentalGetEntityRecordNoResolver,
|
|
614
|
+
canUser,
|
|
615
|
+
canUserEditEntityRecord,
|
|
616
|
+
getAuthors,
|
|
617
|
+
getAutosave,
|
|
618
|
+
getAutosaves,
|
|
619
|
+
getBlockPatternCategories,
|
|
620
|
+
getBlockPatterns,
|
|
621
|
+
getCurrentTheme,
|
|
622
|
+
getCurrentThemeGlobalStylesRevisions,
|
|
623
|
+
getCurrentUser,
|
|
624
|
+
getDefaultTemplateId,
|
|
625
|
+
getEditedEntityRecord,
|
|
626
|
+
getEmbedPreview,
|
|
627
|
+
getEntitiesByKind,
|
|
628
|
+
getEntitiesConfig,
|
|
629
|
+
getEntity,
|
|
630
|
+
getEntityConfig,
|
|
631
|
+
getEntityRecord,
|
|
632
|
+
getEntityRecordEdits,
|
|
633
|
+
getEntityRecordNonTransientEdits,
|
|
634
|
+
getEntityRecords,
|
|
635
|
+
getEntityRecordsTotalItems,
|
|
636
|
+
getEntityRecordsTotalPages,
|
|
637
|
+
getLastEntityDeleteError,
|
|
638
|
+
getLastEntitySaveError,
|
|
639
|
+
getRawEntityRecord,
|
|
640
|
+
getRedoEdit,
|
|
641
|
+
getReferenceByDistinctEdits,
|
|
642
|
+
getRevision,
|
|
643
|
+
getRevisions,
|
|
644
|
+
getThemeSupports,
|
|
645
|
+
getUndoEdit,
|
|
646
|
+
getUserPatternCategories,
|
|
647
|
+
getUserQueryResults,
|
|
648
|
+
hasEditsForEntityRecord,
|
|
649
|
+
hasEntityRecord,
|
|
650
|
+
hasEntityRecords,
|
|
651
|
+
hasFetchedAutosaves,
|
|
652
|
+
hasRedo,
|
|
653
|
+
hasUndo,
|
|
654
|
+
isAutosavingEntityRecord,
|
|
655
|
+
isDeletingEntityRecord,
|
|
656
|
+
isPreviewEmbedFallback,
|
|
657
|
+
isRequestingEmbedPreview,
|
|
658
|
+
isSavingEntityRecord
|
|
1184
659
|
});
|
|
1185
|
-
//# sourceMappingURL=selectors.js.map
|
|
660
|
+
//# sourceMappingURL=selectors.js.map
|