@wordpress/data 10.41.0 → 10.41.1-next.v.202603161435.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (213) hide show
  1. package/README.md +20 -28
  2. package/build/components/async-mode-provider/context.cjs +1 -1
  3. package/build/components/async-mode-provider/context.cjs.map +3 -3
  4. package/build/components/async-mode-provider/index.cjs +1 -1
  5. package/build/components/async-mode-provider/index.cjs.map +1 -1
  6. package/build/components/async-mode-provider/use-async-mode.cjs +1 -1
  7. package/build/components/async-mode-provider/use-async-mode.cjs.map +3 -3
  8. package/build/components/registry-provider/context.cjs +1 -1
  9. package/build/components/registry-provider/context.cjs.map +1 -1
  10. package/build/components/registry-provider/index.cjs +1 -1
  11. package/build/components/registry-provider/index.cjs.map +1 -1
  12. package/build/components/registry-provider/use-registry.cjs +1 -1
  13. package/build/components/registry-provider/use-registry.cjs.map +3 -3
  14. package/build/components/use-dispatch/index.cjs +1 -1
  15. package/build/components/use-dispatch/index.cjs.map +1 -1
  16. package/build/components/use-dispatch/use-dispatch-with-map.cjs +1 -1
  17. package/build/components/use-dispatch/use-dispatch-with-map.cjs.map +3 -3
  18. package/build/components/use-dispatch/use-dispatch.cjs +1 -1
  19. package/build/components/use-dispatch/use-dispatch.cjs.map +3 -3
  20. package/build/components/use-select/index.cjs +2 -2
  21. package/build/components/use-select/index.cjs.map +3 -3
  22. package/build/components/with-dispatch/index.cjs +1 -1
  23. package/build/components/with-dispatch/index.cjs.map +3 -3
  24. package/build/components/with-registry/index.cjs +1 -1
  25. package/build/components/with-registry/index.cjs.map +3 -3
  26. package/build/components/with-select/index.cjs +1 -1
  27. package/build/components/with-select/index.cjs.map +3 -3
  28. package/build/controls.cjs +7 -6
  29. package/build/controls.cjs.map +3 -3
  30. package/build/default-registry.cjs +3 -2
  31. package/build/default-registry.cjs.map +3 -3
  32. package/build/dispatch.cjs +3 -1
  33. package/build/dispatch.cjs.map +2 -2
  34. package/build/factory.cjs.map +2 -2
  35. package/build/index.cjs +9 -8
  36. package/build/index.cjs.map +3 -3
  37. package/build/plugins/index.cjs +1 -1
  38. package/build/plugins/index.cjs.map +1 -1
  39. package/build/plugins/persistence/index.cjs +13 -8
  40. package/build/plugins/persistence/index.cjs.map +3 -3
  41. package/build/plugins/persistence/storage/default.cjs +1 -1
  42. package/build/plugins/persistence/storage/default.cjs.map +3 -3
  43. package/build/plugins/persistence/storage/object.cjs +1 -1
  44. package/build/plugins/persistence/storage/object.cjs.map +3 -3
  45. package/build/promise-middleware.cjs +2 -1
  46. package/build/promise-middleware.cjs.map +3 -3
  47. package/build/redux-store/index.cjs +32 -16
  48. package/build/redux-store/index.cjs.map +3 -3
  49. package/build/redux-store/metadata/selectors.cjs +1 -1
  50. package/build/redux-store/metadata/selectors.cjs.map +3 -3
  51. package/build/redux-store/metadata/types.cjs +19 -0
  52. package/build/redux-store/metadata/types.cjs.map +7 -0
  53. package/build/registry.cjs +11 -7
  54. package/build/registry.cjs.map +3 -3
  55. package/build/resolvers-cache-middleware.cjs +6 -3
  56. package/build/resolvers-cache-middleware.cjs.map +3 -3
  57. package/build/select.cjs +3 -1
  58. package/build/select.cjs.map +2 -2
  59. package/build/store/index.cjs +1 -1
  60. package/build/store/index.cjs.map +3 -3
  61. package/build/types.cjs.map +1 -1
  62. package/build-module/components/async-mode-provider/context.mjs +1 -1
  63. package/build-module/components/async-mode-provider/context.mjs.map +3 -3
  64. package/build-module/components/async-mode-provider/index.mjs +1 -1
  65. package/build-module/components/async-mode-provider/index.mjs.map +1 -1
  66. package/build-module/components/async-mode-provider/use-async-mode.mjs +1 -1
  67. package/build-module/components/async-mode-provider/use-async-mode.mjs.map +3 -3
  68. package/build-module/components/registry-provider/context.mjs +1 -1
  69. package/build-module/components/registry-provider/context.mjs.map +1 -1
  70. package/build-module/components/registry-provider/index.mjs +1 -1
  71. package/build-module/components/registry-provider/index.mjs.map +1 -1
  72. package/build-module/components/registry-provider/use-registry.mjs +1 -1
  73. package/build-module/components/registry-provider/use-registry.mjs.map +3 -3
  74. package/build-module/components/use-dispatch/index.mjs +1 -1
  75. package/build-module/components/use-dispatch/index.mjs.map +1 -1
  76. package/build-module/components/use-dispatch/use-dispatch-with-map.mjs +1 -1
  77. package/build-module/components/use-dispatch/use-dispatch-with-map.mjs.map +3 -3
  78. package/build-module/components/use-dispatch/use-dispatch.mjs +1 -1
  79. package/build-module/components/use-dispatch/use-dispatch.mjs.map +3 -3
  80. package/build-module/components/use-select/index.mjs +2 -2
  81. package/build-module/components/use-select/index.mjs.map +3 -3
  82. package/build-module/components/with-dispatch/index.mjs +1 -1
  83. package/build-module/components/with-dispatch/index.mjs.map +3 -3
  84. package/build-module/components/with-registry/index.mjs +1 -1
  85. package/build-module/components/with-registry/index.mjs.map +3 -3
  86. package/build-module/components/with-select/index.mjs +1 -1
  87. package/build-module/components/with-select/index.mjs.map +3 -3
  88. package/build-module/controls.mjs +7 -6
  89. package/build-module/controls.mjs.map +3 -3
  90. package/build-module/default-registry.mjs +3 -2
  91. package/build-module/default-registry.mjs.map +3 -3
  92. package/build-module/dispatch.mjs +3 -1
  93. package/build-module/dispatch.mjs.map +2 -2
  94. package/build-module/factory.mjs.map +2 -2
  95. package/build-module/index.mjs +4 -3
  96. package/build-module/index.mjs.map +2 -2
  97. package/build-module/plugins/index.mjs +1 -1
  98. package/build-module/plugins/index.mjs.map +1 -1
  99. package/build-module/plugins/persistence/index.mjs +13 -8
  100. package/build-module/plugins/persistence/index.mjs.map +3 -3
  101. package/build-module/plugins/persistence/storage/default.mjs +1 -1
  102. package/build-module/plugins/persistence/storage/default.mjs.map +3 -3
  103. package/build-module/plugins/persistence/storage/object.mjs +1 -1
  104. package/build-module/plugins/persistence/storage/object.mjs.map +3 -3
  105. package/build-module/promise-middleware.mjs +2 -1
  106. package/build-module/promise-middleware.mjs.map +3 -3
  107. package/build-module/redux-store/index.mjs +32 -16
  108. package/build-module/redux-store/index.mjs.map +3 -3
  109. package/build-module/redux-store/metadata/selectors.mjs +1 -1
  110. package/build-module/redux-store/metadata/selectors.mjs.map +3 -3
  111. package/build-module/redux-store/metadata/types.mjs +1 -0
  112. package/build-module/redux-store/metadata/types.mjs.map +7 -0
  113. package/build-module/registry.mjs +11 -7
  114. package/build-module/registry.mjs.map +3 -3
  115. package/build-module/resolvers-cache-middleware.mjs +6 -3
  116. package/build-module/resolvers-cache-middleware.mjs.map +3 -3
  117. package/build-module/select.mjs +3 -1
  118. package/build-module/select.mjs.map +2 -2
  119. package/build-module/store/index.mjs +1 -1
  120. package/build-module/store/index.mjs.map +3 -3
  121. package/build-types/components/async-mode-provider/context.d.ts +37 -3
  122. package/build-types/components/async-mode-provider/context.d.ts.map +1 -1
  123. package/build-types/components/async-mode-provider/index.d.ts +2 -2
  124. package/build-types/components/async-mode-provider/index.d.ts.map +1 -1
  125. package/build-types/components/async-mode-provider/use-async-mode.d.ts.map +1 -1
  126. package/build-types/components/registry-provider/context.d.ts +10 -3
  127. package/build-types/components/registry-provider/context.d.ts.map +1 -1
  128. package/build-types/components/registry-provider/index.d.ts +2 -2
  129. package/build-types/components/registry-provider/index.d.ts.map +1 -1
  130. package/build-types/components/registry-provider/use-registry.d.ts +3 -2
  131. package/build-types/components/registry-provider/use-registry.d.ts.map +1 -1
  132. package/build-types/components/use-dispatch/index.d.ts +2 -2
  133. package/build-types/components/use-dispatch/index.d.ts.map +1 -1
  134. package/build-types/components/use-dispatch/use-dispatch-with-map.d.ts +11 -9
  135. package/build-types/components/use-dispatch/use-dispatch-with-map.d.ts.map +1 -1
  136. package/build-types/components/use-dispatch/use-dispatch.d.ts +10 -19
  137. package/build-types/components/use-dispatch/use-dispatch.d.ts.map +1 -1
  138. package/build-types/components/use-select/index.d.ts +24 -28
  139. package/build-types/components/use-select/index.d.ts.map +1 -1
  140. package/build-types/components/with-dispatch/index.d.ts +10 -11
  141. package/build-types/components/with-dispatch/index.d.ts.map +1 -1
  142. package/build-types/components/with-registry/index.d.ts +2 -6
  143. package/build-types/components/with-registry/index.d.ts.map +1 -1
  144. package/build-types/components/with-select/index.d.ts +7 -8
  145. package/build-types/components/with-select/index.d.ts.map +1 -1
  146. package/build-types/controls.d.ts +57 -44
  147. package/build-types/controls.d.ts.map +1 -1
  148. package/build-types/default-registry.d.ts +2 -2
  149. package/build-types/default-registry.d.ts.map +1 -1
  150. package/build-types/dispatch.d.ts +4 -0
  151. package/build-types/dispatch.d.ts.map +1 -1
  152. package/build-types/factory.d.ts +2 -1
  153. package/build-types/factory.d.ts.map +1 -1
  154. package/build-types/index.d.ts.map +1 -1
  155. package/build-types/plugins/index.d.ts +1 -1
  156. package/build-types/plugins/index.d.ts.map +1 -1
  157. package/build-types/plugins/persistence/index.d.ts +38 -27
  158. package/build-types/plugins/persistence/index.d.ts.map +1 -1
  159. package/build-types/plugins/persistence/storage/default.d.ts +7 -1
  160. package/build-types/plugins/persistence/storage/default.d.ts.map +1 -1
  161. package/build-types/plugins/persistence/storage/object.d.ts +4 -5
  162. package/build-types/plugins/persistence/storage/object.d.ts.map +1 -1
  163. package/build-types/promise-middleware.d.ts +6 -4
  164. package/build-types/promise-middleware.d.ts.map +1 -1
  165. package/build-types/redux-store/index.d.ts +12 -15
  166. package/build-types/redux-store/index.d.ts.map +1 -1
  167. package/build-types/redux-store/metadata/selectors.d.ts +45 -50
  168. package/build-types/redux-store/metadata/selectors.d.ts.map +1 -1
  169. package/build-types/redux-store/metadata/types.d.ts +48 -0
  170. package/build-types/redux-store/metadata/types.d.ts.map +1 -0
  171. package/build-types/registry.d.ts +5 -49
  172. package/build-types/registry.d.ts.map +1 -1
  173. package/build-types/resolvers-cache-middleware.d.ts +13 -7
  174. package/build-types/resolvers-cache-middleware.d.ts.map +1 -1
  175. package/build-types/select.d.ts +3 -0
  176. package/build-types/select.d.ts.map +1 -1
  177. package/build-types/store/index.d.ts +5 -12
  178. package/build-types/store/index.d.ts.map +1 -1
  179. package/build-types/types.d.ts +201 -10
  180. package/build-types/types.d.ts.map +1 -1
  181. package/package.json +9 -9
  182. package/src/components/async-mode-provider/{context.js → context.ts} +0 -1
  183. package/src/components/async-mode-provider/{use-async-mode.js → use-async-mode.ts} +1 -1
  184. package/src/components/registry-provider/{use-registry.js → use-registry.ts} +3 -2
  185. package/src/components/use-dispatch/{use-dispatch-with-map.js → use-dispatch-with-map.ts} +18 -9
  186. package/src/components/use-dispatch/{use-dispatch.js → use-dispatch.ts} +25 -20
  187. package/src/components/use-select/{index.js → index.ts} +84 -70
  188. package/src/components/with-dispatch/{index.js → index.tsx} +20 -13
  189. package/src/components/with-registry/{index.js → index.tsx} +1 -5
  190. package/src/components/with-select/{index.js → index.tsx} +17 -10
  191. package/src/{controls.js → controls.ts} +53 -26
  192. package/src/{default-registry.js → default-registry.ts} +3 -1
  193. package/src/dispatch.ts +7 -1
  194. package/src/factory.ts +4 -3
  195. package/src/index.ts +4 -8
  196. package/src/plugins/persistence/{index.js → index.ts} +93 -54
  197. package/src/plugins/persistence/storage/{default.js → default.ts} +3 -2
  198. package/src/plugins/persistence/storage/object.ts +25 -0
  199. package/src/{promise-middleware.js → promise-middleware.ts} +3 -3
  200. package/src/redux-store/{index.js → index.ts} +218 -131
  201. package/src/redux-store/metadata/{selectors.js → selectors.ts} +83 -54
  202. package/src/redux-store/metadata/types.ts +100 -0
  203. package/src/{registry.js → registry.ts} +98 -88
  204. package/src/{resolvers-cache-middleware.js → resolvers-cache-middleware.ts} +22 -7
  205. package/src/select.ts +6 -1
  206. package/src/store/{index.js → index.ts} +13 -8
  207. package/src/types.ts +263 -24
  208. package/src/plugins/persistence/storage/object.js +0 -23
  209. /package/src/components/async-mode-provider/{index.js → index.ts} +0 -0
  210. /package/src/components/registry-provider/{context.js → context.ts} +0 -0
  211. /package/src/components/registry-provider/{index.js → index.ts} +0 -0
  212. /package/src/components/use-dispatch/{index.js → index.ts} +0 -0
  213. /package/src/plugins/{index.js → index.ts} +0 -0
@@ -8,10 +8,7 @@ import deprecated from '@wordpress/deprecated';
8
8
  */
9
9
  import { createSelector } from '../../create-selector';
10
10
  import { selectorArgsToStateKey } from './utils';
11
-
12
- /** @typedef {Record<string, import('./reducer').State>} State */
13
- /** @typedef {import('./reducer').StateValue} StateValue */
14
- /** @typedef {import('./reducer').Status} Status */
11
+ import type { State, StateValue } from './reducer';
15
12
 
16
13
  /**
17
14
  * Returns the raw resolution state value for a given selector name,
@@ -19,13 +16,17 @@ import { selectorArgsToStateKey } from './utils';
19
16
  * or not resolved for the given set of arguments, otherwise true or false for
20
17
  * resolution started and completed respectively.
21
18
  *
22
- * @param {State} state Data state.
23
- * @param {string} selectorName Selector name.
24
- * @param {unknown[]?} args Arguments passed to selector.
19
+ * @param state Data state.
20
+ * @param selectorName Selector name.
21
+ * @param args Arguments passed to selector.
25
22
  *
26
- * @return {StateValue|undefined} isResolving value.
23
+ * @return isResolving value.
27
24
  */
28
- export function getResolutionState( state, selectorName, args ) {
25
+ export function getResolutionState(
26
+ state: Record< string, State >,
27
+ selectorName: string,
28
+ args?: unknown[] | null
29
+ ): StateValue | undefined {
29
30
  const map = state[ selectorName ];
30
31
  if ( ! map ) {
31
32
  return;
@@ -46,13 +47,17 @@ export function getResolutionState( state, selectorName, args ) {
46
47
  *
47
48
  * @deprecated
48
49
  *
49
- * @param {State} state Data state.
50
- * @param {string} selectorName Selector name.
51
- * @param {unknown[]?} args Arguments passed to selector.
50
+ * @param state Data state.
51
+ * @param selectorName Selector name.
52
+ * @param args Arguments passed to selector.
52
53
  *
53
- * @return {boolean | undefined} isResolving value.
54
+ * @return isResolving value.
54
55
  */
55
- export function getIsResolving( state, selectorName, args ) {
56
+ export function getIsResolving(
57
+ state: Record< string, State >,
58
+ selectorName: string,
59
+ args?: unknown[] | null
60
+ ): boolean | undefined {
56
61
  deprecated( 'wp.data.select( store ).getIsResolving', {
57
62
  since: '6.6',
58
63
  version: '6.8',
@@ -67,13 +72,17 @@ export function getIsResolving( state, selectorName, args ) {
67
72
  * Returns true if resolution has already been triggered for a given
68
73
  * selector name, and arguments set.
69
74
  *
70
- * @param {State} state Data state.
71
- * @param {string} selectorName Selector name.
72
- * @param {unknown[]?} args Arguments passed to selector.
75
+ * @param state Data state.
76
+ * @param selectorName Selector name.
77
+ * @param args Arguments passed to selector.
73
78
  *
74
- * @return {boolean} Whether resolution has been triggered.
79
+ * @return Whether resolution has been triggered.
75
80
  */
76
- export function hasStartedResolution( state, selectorName, args ) {
81
+ export function hasStartedResolution(
82
+ state: Record< string, State >,
83
+ selectorName: string,
84
+ args?: unknown[] | null
85
+ ): boolean {
77
86
  return getResolutionState( state, selectorName, args ) !== undefined;
78
87
  }
79
88
 
@@ -81,13 +90,17 @@ export function hasStartedResolution( state, selectorName, args ) {
81
90
  * Returns true if resolution has completed for a given selector
82
91
  * name, and arguments set.
83
92
  *
84
- * @param {State} state Data state.
85
- * @param {string} selectorName Selector name.
86
- * @param {unknown[]?} args Arguments passed to selector.
93
+ * @param state Data state.
94
+ * @param selectorName Selector name.
95
+ * @param args Arguments passed to selector.
87
96
  *
88
- * @return {boolean} Whether resolution has completed.
97
+ * @return Whether resolution has completed.
89
98
  */
90
- export function hasFinishedResolution( state, selectorName, args ) {
99
+ export function hasFinishedResolution(
100
+ state: Record< string, State >,
101
+ selectorName: string,
102
+ args?: unknown[] | null
103
+ ): boolean {
91
104
  const status = getResolutionState( state, selectorName, args )?.status;
92
105
  return status === 'finished' || status === 'error';
93
106
  }
@@ -96,13 +109,17 @@ export function hasFinishedResolution( state, selectorName, args ) {
96
109
  * Returns true if resolution has failed for a given selector
97
110
  * name, and arguments set.
98
111
  *
99
- * @param {State} state Data state.
100
- * @param {string} selectorName Selector name.
101
- * @param {unknown[]?} args Arguments passed to selector.
112
+ * @param state Data state.
113
+ * @param selectorName Selector name.
114
+ * @param args Arguments passed to selector.
102
115
  *
103
- * @return {boolean} Has resolution failed
116
+ * @return Has resolution failed
104
117
  */
105
- export function hasResolutionFailed( state, selectorName, args ) {
118
+ export function hasResolutionFailed(
119
+ state: Record< string, State >,
120
+ selectorName: string,
121
+ args?: unknown[] | null
122
+ ): boolean {
106
123
  return getResolutionState( state, selectorName, args )?.status === 'error';
107
124
  }
108
125
 
@@ -111,13 +128,17 @@ export function hasResolutionFailed( state, selectorName, args ) {
111
128
  * Note it may be of an Error type, but may also be null, undefined, or anything else
112
129
  * that can be `throw`-n.
113
130
  *
114
- * @param {State} state Data state.
115
- * @param {string} selectorName Selector name.
116
- * @param {unknown[]?} args Arguments passed to selector.
131
+ * @param state Data state.
132
+ * @param selectorName Selector name.
133
+ * @param args Arguments passed to selector.
117
134
  *
118
- * @return {Error|unknown} Last resolution error
135
+ * @return Last resolution error
119
136
  */
120
- export function getResolutionError( state, selectorName, args ) {
137
+ export function getResolutionError(
138
+ state: Record< string, State >,
139
+ selectorName: string,
140
+ args?: unknown[] | null
141
+ ): Error | unknown {
121
142
  const resolutionState = getResolutionState( state, selectorName, args );
122
143
  return resolutionState?.status === 'error' ? resolutionState.error : null;
123
144
  }
@@ -126,13 +147,17 @@ export function getResolutionError( state, selectorName, args ) {
126
147
  * Returns true if resolution has been triggered but has not yet completed for
127
148
  * a given selector name, and arguments set.
128
149
  *
129
- * @param {State} state Data state.
130
- * @param {string} selectorName Selector name.
131
- * @param {unknown[]?} args Arguments passed to selector.
150
+ * @param state Data state.
151
+ * @param selectorName Selector name.
152
+ * @param args Arguments passed to selector.
132
153
  *
133
- * @return {boolean} Whether resolution is in progress.
154
+ * @return Whether resolution is in progress.
134
155
  */
135
- export function isResolving( state, selectorName, args ) {
156
+ export function isResolving(
157
+ state: Record< string, State >,
158
+ selectorName: string,
159
+ args?: unknown[] | null
160
+ ): boolean {
136
161
  return (
137
162
  getResolutionState( state, selectorName, args )?.status === 'resolving'
138
163
  );
@@ -141,22 +166,26 @@ export function isResolving( state, selectorName, args ) {
141
166
  /**
142
167
  * Returns the list of the cached resolvers.
143
168
  *
144
- * @param {State} state Data state.
169
+ * @param state Data state.
145
170
  *
146
- * @return {State} Resolvers mapped by args and selectorName.
171
+ * @return Resolvers mapped by args and selectorName.
147
172
  */
148
- export function getCachedResolvers( state ) {
173
+ export function getCachedResolvers(
174
+ state: Record< string, State >
175
+ ): Record< string, State > {
149
176
  return state;
150
177
  }
151
178
 
152
179
  /**
153
180
  * Whether the store has any currently resolving selectors.
154
181
  *
155
- * @param {State} state Data state.
182
+ * @param state Data state.
156
183
  *
157
- * @return {boolean} True if one or more selectors are resolving, false otherwise.
184
+ * @return True if one or more selectors are resolving, false otherwise.
158
185
  */
159
- export function hasResolvingSelectors( state ) {
186
+ export function hasResolvingSelectors(
187
+ state: Record< string, State >
188
+ ): boolean {
160
189
  return Object.values( state ).some( ( selectorState ) =>
161
190
  /**
162
191
  * This uses the internal `_map` property of `EquivalentKeyMap` for
@@ -165,8 +194,8 @@ export function hasResolvingSelectors( state ) {
165
194
  *
166
195
  * @see https://github.com/aduth/equivalent-key-map
167
196
  */
168
- Array.from( selectorState._map.values() ).some(
169
- ( resolution ) => resolution[ 1 ]?.status === 'resolving'
197
+ Array.from( ( selectorState as any )._map.values() ).some(
198
+ ( resolution: any ) => resolution[ 1 ]?.status === 'resolving'
170
199
  )
171
200
  );
172
201
  }
@@ -174,13 +203,13 @@ export function hasResolvingSelectors( state ) {
174
203
  /**
175
204
  * Retrieves the total number of selectors, grouped per status.
176
205
  *
177
- * @param {State} state Data state.
206
+ * @param state Data state.
178
207
  *
179
- * @return {Object} Object, containing selector totals by status.
208
+ * @return Object, containing selector totals by status.
180
209
  */
181
210
  export const countSelectorsByStatus = createSelector(
182
- ( state ) => {
183
- const selectorsByStatus = {};
211
+ ( state: Record< string, State > ): Record< string, number > => {
212
+ const selectorsByStatus: Record< string, number > = {};
184
213
 
185
214
  Object.values( state ).forEach( ( selectorState ) =>
186
215
  /**
@@ -190,8 +219,8 @@ export const countSelectorsByStatus = createSelector(
190
219
  *
191
220
  * @see https://github.com/aduth/equivalent-key-map
192
221
  */
193
- Array.from( selectorState._map.values() ).forEach(
194
- ( resolution ) => {
222
+ Array.from( ( selectorState as any )._map.values() ).forEach(
223
+ ( resolution: any ) => {
195
224
  const currentStatus = resolution[ 1 ]?.status ?? 'error';
196
225
  if ( ! selectorsByStatus[ currentStatus ] ) {
197
226
  selectorsByStatus[ currentStatus ] = 0;
@@ -203,5 +232,5 @@ export const countSelectorsByStatus = createSelector(
203
232
 
204
233
  return selectorsByStatus;
205
234
  },
206
- ( state ) => [ state ]
235
+ ( state: Record< string, State > ) => [ state ]
207
236
  );
@@ -0,0 +1,100 @@
1
+ /**
2
+ * Internal dependencies
3
+ */
4
+ import type { StoreDescriptor, ReduxStoreConfig } from '../../types';
5
+ import type { StateValue as MetadataStateValue } from './reducer';
6
+
7
+ /**
8
+ * Extracts selector key names from a store descriptor.
9
+ * Falls back to `string` when the store type is unknown.
10
+ */
11
+ export type SelectorKeysOf< S > = S extends StoreDescriptor<
12
+ ReduxStoreConfig< any, any, infer Selectors >
13
+ >
14
+ ? string & keyof Selectors
15
+ : string;
16
+
17
+ /**
18
+ * Metadata selectors injected into every Redux store.
19
+ *
20
+ * These are resolution-tracking selectors that the data module
21
+ * automatically adds to every registered store. The `S` parameter
22
+ * provides type-safe selector names via `SelectorKeysOf`.
23
+ */
24
+ export type MetadataSelectors< S = unknown > = {
25
+ getResolutionState: (
26
+ selectorName: SelectorKeysOf< S >,
27
+ args?: unknown[] | null
28
+ ) => MetadataStateValue | undefined;
29
+ getIsResolving: (
30
+ selectorName: SelectorKeysOf< S >,
31
+ args?: unknown[] | null
32
+ ) => boolean | undefined;
33
+ hasStartedResolution: (
34
+ selectorName: SelectorKeysOf< S >,
35
+ args?: unknown[] | null
36
+ ) => boolean;
37
+ hasFinishedResolution: (
38
+ selectorName: SelectorKeysOf< S >,
39
+ args?: unknown[] | null
40
+ ) => boolean;
41
+ hasResolutionFailed: (
42
+ selectorName: SelectorKeysOf< S >,
43
+ args?: unknown[] | null
44
+ ) => boolean;
45
+ getResolutionError: (
46
+ selectorName: SelectorKeysOf< S >,
47
+ args?: unknown[] | null
48
+ ) => Error | unknown;
49
+ isResolving: (
50
+ selectorName: SelectorKeysOf< S >,
51
+ args?: unknown[] | null
52
+ ) => boolean;
53
+ getCachedResolvers: () => Record< string, unknown >;
54
+ hasResolvingSelectors: () => boolean;
55
+ countSelectorsByStatus: () => Record< string, number >;
56
+ };
57
+
58
+ /**
59
+ * Metadata actions injected into every Redux store.
60
+ *
61
+ * These are resolution-tracking actions that the data module
62
+ * automatically adds to every registered store. The `S` parameter
63
+ * provides type-safe selector names via `SelectorKeysOf`.
64
+ */
65
+ export type MetadataActions< S = unknown > = {
66
+ startResolution: (
67
+ selectorName: SelectorKeysOf< S >,
68
+ args: unknown[]
69
+ ) => Promise< void >;
70
+ finishResolution: (
71
+ selectorName: SelectorKeysOf< S >,
72
+ args: unknown[]
73
+ ) => Promise< void >;
74
+ failResolution: (
75
+ selectorName: SelectorKeysOf< S >,
76
+ args: unknown[],
77
+ error: Error | unknown
78
+ ) => Promise< void >;
79
+ startResolutions: (
80
+ selectorName: SelectorKeysOf< S >,
81
+ args: unknown[][]
82
+ ) => Promise< void >;
83
+ finishResolutions: (
84
+ selectorName: SelectorKeysOf< S >,
85
+ args: unknown[][]
86
+ ) => Promise< void >;
87
+ failResolutions: (
88
+ selectorName: SelectorKeysOf< S >,
89
+ args: unknown[],
90
+ errors: ( Error | unknown )[]
91
+ ) => Promise< void >;
92
+ invalidateResolution: (
93
+ selectorName: SelectorKeysOf< S >,
94
+ args: unknown[]
95
+ ) => Promise< void >;
96
+ invalidateResolutionForStore: () => Promise< void >;
97
+ invalidateResolutionForStoreSelector: (
98
+ selectorName: SelectorKeysOf< S >
99
+ ) => Promise< void >;
100
+ };