@automattic/data-stores 3.1.2 → 3.2.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 (181) hide show
  1. package/CHANGELOG.md +14 -1
  2. package/dist/cjs/contextual-help/admin-sections.js +1 -1
  3. package/dist/cjs/contextual-help/admin-sections.js.map +1 -1
  4. package/dist/cjs/help-center/actions.js +79 -49
  5. package/dist/cjs/help-center/actions.js.map +1 -1
  6. package/dist/cjs/help-center/reducer.js +19 -10
  7. package/dist/cjs/help-center/reducer.js.map +1 -1
  8. package/dist/cjs/help-center/resolvers.js +2 -1
  9. package/dist/cjs/help-center/resolvers.js.map +1 -1
  10. package/dist/cjs/help-center/selectors.js +7 -5
  11. package/dist/cjs/help-center/selectors.js.map +1 -1
  12. package/dist/cjs/index.js +1 -4
  13. package/dist/cjs/index.js.map +1 -1
  14. package/dist/cjs/onboard/actions.js +11 -1
  15. package/dist/cjs/onboard/actions.js.map +1 -1
  16. package/dist/cjs/onboard/reducer.js +23 -1
  17. package/dist/cjs/onboard/reducer.js.map +1 -1
  18. package/dist/cjs/onboard/selectors.js +5 -1
  19. package/dist/cjs/onboard/selectors.js.map +1 -1
  20. package/dist/cjs/plans/queries/use-plans.js +20 -1
  21. package/dist/cjs/plans/queries/use-plans.js.map +1 -1
  22. package/dist/cjs/purchases/lib/assembler.js +6 -16
  23. package/dist/cjs/purchases/lib/assembler.js.map +1 -1
  24. package/dist/cjs/site/types.js.map +1 -1
  25. package/dist/esm/contextual-help/admin-sections.js +1 -1
  26. package/dist/esm/contextual-help/admin-sections.js.map +1 -1
  27. package/dist/esm/help-center/actions.js +74 -46
  28. package/dist/esm/help-center/actions.js.map +1 -1
  29. package/dist/esm/help-center/reducer.js +19 -10
  30. package/dist/esm/help-center/reducer.js.map +1 -1
  31. package/dist/esm/help-center/resolvers.js +3 -2
  32. package/dist/esm/help-center/resolvers.js.map +1 -1
  33. package/dist/esm/help-center/selectors.js +3 -2
  34. package/dist/esm/help-center/selectors.js.map +1 -1
  35. package/dist/esm/index.js +1 -3
  36. package/dist/esm/index.js.map +1 -1
  37. package/dist/esm/onboard/actions.js +8 -0
  38. package/dist/esm/onboard/actions.js.map +1 -1
  39. package/dist/esm/onboard/reducer.js +20 -0
  40. package/dist/esm/onboard/reducer.js.map +1 -1
  41. package/dist/esm/onboard/selectors.js +2 -0
  42. package/dist/esm/onboard/selectors.js.map +1 -1
  43. package/dist/esm/plans/queries/use-plans.js +20 -1
  44. package/dist/esm/plans/queries/use-plans.js.map +1 -1
  45. package/dist/esm/purchases/lib/assembler.js +6 -16
  46. package/dist/esm/purchases/lib/assembler.js.map +1 -1
  47. package/dist/esm/site/types.js.map +1 -1
  48. package/dist/tsconfig-cjs.tsbuildinfo +1 -1
  49. package/dist/tsconfig.tsbuildinfo +1 -1
  50. package/dist/types/help-center/actions.d.ts +30 -14
  51. package/dist/types/help-center/actions.d.ts.map +1 -1
  52. package/dist/types/help-center/reducer.d.ts +6 -5
  53. package/dist/types/help-center/reducer.d.ts.map +1 -1
  54. package/dist/types/help-center/resolvers.d.ts +16 -8
  55. package/dist/types/help-center/resolvers.d.ts.map +1 -1
  56. package/dist/types/help-center/selectors.d.ts +3 -2
  57. package/dist/types/help-center/selectors.d.ts.map +1 -1
  58. package/dist/types/help-center/types.d.ts +1 -0
  59. package/dist/types/help-center/types.d.ts.map +1 -1
  60. package/dist/types/index.d.ts +473 -43
  61. package/dist/types/index.d.ts.map +1 -1
  62. package/dist/types/onboard/actions.d.ts +14 -2
  63. package/dist/types/onboard/actions.d.ts.map +1 -1
  64. package/dist/types/onboard/reducer.d.ts +7 -1
  65. package/dist/types/onboard/reducer.d.ts.map +1 -1
  66. package/dist/types/onboard/selectors.d.ts +6 -2
  67. package/dist/types/onboard/selectors.d.ts.map +1 -1
  68. package/dist/types/onboard/types.d.ts +1 -1
  69. package/dist/types/onboard/types.d.ts.map +1 -1
  70. package/dist/types/plans/queries/use-plans.d.ts.map +1 -1
  71. package/dist/types/purchases/lib/assembler.d.ts +3 -3
  72. package/dist/types/purchases/lib/assembler.d.ts.map +1 -1
  73. package/dist/types/purchases/types.d.ts +3 -109
  74. package/dist/types/purchases/types.d.ts.map +1 -1
  75. package/dist/types/queries/use-all-domains-query.d.ts +1 -1
  76. package/dist/types/queries/use-all-domains-query.d.ts.map +1 -1
  77. package/dist/types/queries/use-site-domains-query.d.ts +1 -1
  78. package/dist/types/queries/use-site-domains-query.d.ts.map +1 -1
  79. package/dist/types/queries/use-site-query.d.ts +1 -1
  80. package/dist/types/queries/use-site-query.d.ts.map +1 -1
  81. package/dist/types/reader/index.d.ts +472 -40
  82. package/dist/types/reader/index.d.ts.map +1 -1
  83. package/dist/types/reader/queries/use-pending-post-subscriptions-query.d.ts +75 -7
  84. package/dist/types/reader/queries/use-pending-post-subscriptions-query.d.ts.map +1 -1
  85. package/dist/types/reader/queries/use-pending-site-subscriptions-query.d.ts +75 -7
  86. package/dist/types/reader/queries/use-pending-site-subscriptions-query.d.ts.map +1 -1
  87. package/dist/types/reader/queries/use-post-subscriptions-query.d.ts +143 -13
  88. package/dist/types/reader/queries/use-post-subscriptions-query.d.ts.map +1 -1
  89. package/dist/types/reader/queries/use-site-subscriptions-query.d.ts +103 -13
  90. package/dist/types/reader/queries/use-site-subscriptions-query.d.ts.map +1 -1
  91. package/dist/types/site/types.d.ts +2 -0
  92. package/dist/types/site/types.d.ts.map +1 -1
  93. package/dist/types/user/actions.d.ts +1 -1
  94. package/dist/types/user/reducer.d.ts +1 -1
  95. package/dist/types/user/resolvers.d.ts +2 -2
  96. package/dist/types/user/selectors.d.ts +2 -2
  97. package/dist/types/user/selectors.d.ts.map +1 -1
  98. package/dist/types/user/types.d.ts +2 -33
  99. package/dist/types/user/types.d.ts.map +1 -1
  100. package/package.json +4 -8
  101. package/src/contextual-help/admin-sections.ts +1 -1
  102. package/src/help-center/actions.ts +85 -50
  103. package/src/help-center/reducer.ts +27 -15
  104. package/src/help-center/resolvers.ts +15 -8
  105. package/src/help-center/selectors.ts +4 -2
  106. package/src/help-center/types.ts +1 -0
  107. package/src/index.ts +0 -3
  108. package/src/onboard/actions.ts +13 -1
  109. package/src/onboard/reducer.ts +26 -1
  110. package/src/onboard/selectors.ts +2 -0
  111. package/src/onboard/types.ts +1 -1
  112. package/src/plans/queries/use-plans.ts +29 -1
  113. package/src/purchases/lib/assembler.ts +10 -25
  114. package/src/purchases/types.ts +4 -116
  115. package/src/site/types.ts +2 -0
  116. package/src/user/types.ts +2 -38
  117. package/dist/cjs/domain-suggestions/actions.js +0 -33
  118. package/dist/cjs/domain-suggestions/actions.js.map +0 -1
  119. package/dist/cjs/domain-suggestions/constants.js +0 -12
  120. package/dist/cjs/domain-suggestions/constants.js.map +0 -1
  121. package/dist/cjs/domain-suggestions/index.js +0 -25
  122. package/dist/cjs/domain-suggestions/index.js.map +0 -1
  123. package/dist/cjs/domain-suggestions/queries.js +0 -78
  124. package/dist/cjs/domain-suggestions/queries.js.map +0 -1
  125. package/dist/cjs/domain-suggestions/reducer.js +0 -65
  126. package/dist/cjs/domain-suggestions/reducer.js.map +0 -1
  127. package/dist/cjs/domain-suggestions/resolvers.js +0 -91
  128. package/dist/cjs/domain-suggestions/resolvers.js.map +0 -1
  129. package/dist/cjs/domain-suggestions/selectors.js +0 -58
  130. package/dist/cjs/domain-suggestions/selectors.js.map +0 -1
  131. package/dist/cjs/domain-suggestions/types.js +0 -3
  132. package/dist/cjs/domain-suggestions/types.js.map +0 -1
  133. package/dist/cjs/domain-suggestions/utils.js +0 -47
  134. package/dist/cjs/domain-suggestions/utils.js.map +0 -1
  135. package/dist/esm/domain-suggestions/actions.js +0 -25
  136. package/dist/esm/domain-suggestions/actions.js.map +0 -1
  137. package/dist/esm/domain-suggestions/constants.js +0 -9
  138. package/dist/esm/domain-suggestions/constants.js.map +0 -1
  139. package/dist/esm/domain-suggestions/index.js +0 -20
  140. package/dist/esm/domain-suggestions/index.js.map +0 -1
  141. package/dist/esm/domain-suggestions/queries.js +0 -72
  142. package/dist/esm/domain-suggestions/queries.js.map +0 -1
  143. package/dist/esm/domain-suggestions/reducer.js +0 -61
  144. package/dist/esm/domain-suggestions/reducer.js.map +0 -1
  145. package/dist/esm/domain-suggestions/resolvers.js +0 -84
  146. package/dist/esm/domain-suggestions/resolvers.js.map +0 -1
  147. package/dist/esm/domain-suggestions/selectors.js +0 -47
  148. package/dist/esm/domain-suggestions/selectors.js.map +0 -1
  149. package/dist/esm/domain-suggestions/types.js +0 -2
  150. package/dist/esm/domain-suggestions/types.js.map +0 -1
  151. package/dist/esm/domain-suggestions/utils.js +0 -41
  152. package/dist/esm/domain-suggestions/utils.js.map +0 -1
  153. package/dist/types/domain-suggestions/actions.d.ts +0 -27
  154. package/dist/types/domain-suggestions/actions.d.ts.map +0 -1
  155. package/dist/types/domain-suggestions/constants.d.ts +0 -8
  156. package/dist/types/domain-suggestions/constants.d.ts.map +0 -1
  157. package/dist/types/domain-suggestions/index.d.ts +0 -10
  158. package/dist/types/domain-suggestions/index.d.ts.map +0 -1
  159. package/dist/types/domain-suggestions/queries.d.ts +0 -323
  160. package/dist/types/domain-suggestions/queries.d.ts.map +0 -1
  161. package/dist/types/domain-suggestions/reducer.d.ts +0 -16
  162. package/dist/types/domain-suggestions/reducer.d.ts.map +0 -1
  163. package/dist/types/domain-suggestions/resolvers.d.ts +0 -39
  164. package/dist/types/domain-suggestions/resolvers.d.ts.map +0 -1
  165. package/dist/types/domain-suggestions/selectors.d.ts +0 -18
  166. package/dist/types/domain-suggestions/selectors.d.ts.map +0 -1
  167. package/dist/types/domain-suggestions/types.d.ts +0 -206
  168. package/dist/types/domain-suggestions/types.d.ts.map +0 -1
  169. package/dist/types/domain-suggestions/utils.d.ts +0 -23
  170. package/dist/types/domain-suggestions/utils.d.ts.map +0 -1
  171. package/src/domain-suggestions/actions.ts +0 -51
  172. package/src/domain-suggestions/constants.ts +0 -8
  173. package/src/domain-suggestions/index.ts +0 -22
  174. package/src/domain-suggestions/queries.ts +0 -85
  175. package/src/domain-suggestions/reducer.ts +0 -77
  176. package/src/domain-suggestions/resolvers.ts +0 -110
  177. package/src/domain-suggestions/selectors.ts +0 -86
  178. package/src/domain-suggestions/test/reducer.ts +0 -105
  179. package/src/domain-suggestions/test/selectors.ts +0 -127
  180. package/src/domain-suggestions/types.ts +0 -254
  181. package/src/domain-suggestions/utils.ts +0 -50
@@ -1,254 +0,0 @@
1
- import type { DataStatus } from './constants';
2
-
3
- export interface DomainSuggestionQuery {
4
- /**
5
- * True to include .blog subdomain suggestions
6
- * @example
7
- * example.photo.blog
8
- */
9
- include_dotblogsubdomain: boolean;
10
-
11
- /**
12
- * True to include WordPress.com subdomain suggestions
13
- * @example
14
- * example.wordpress.com
15
- */
16
- include_wordpressdotcom: boolean;
17
-
18
- /**
19
- * True to include domains registered with wpcom in the response
20
- */
21
- include_internal_move_eligible?: boolean;
22
-
23
- /**
24
- * Localizes domain results, e.g., price format
25
- */
26
- locale?: string;
27
-
28
- /**
29
- * True to only provide a wordpress.com subdomain
30
- * @example
31
- * example.wordpress.com
32
- */
33
- only_wordpressdotcom: boolean;
34
-
35
- /**
36
- * Desired number of results
37
- */
38
- quantity: number;
39
-
40
- /**
41
- * Domain search term
42
- */
43
- query: string;
44
-
45
- recommendation_context?: string;
46
-
47
- /**
48
- * Vendor
49
- */
50
- vendor: string;
51
-
52
- /**
53
- * The vertical id or slug
54
- */
55
- vertical?: string;
56
-
57
- /**
58
- * An array of tlds
59
- */
60
- tlds?: readonly string[];
61
-
62
- /**
63
- * Domain category slug
64
- */
65
- category_slug?: string;
66
- }
67
-
68
- export type DomainName = string;
69
-
70
- export interface DomainSuggestion {
71
- /**
72
- * The domain name
73
- * @example "example.com"
74
- */
75
- domain_name: DomainName;
76
-
77
- /**
78
- * Rendered formatted cost
79
- * @example "Free" or "€15.00"
80
- */
81
- cost: string;
82
-
83
- /**
84
- * Raw price
85
- * @example 40
86
- */
87
- raw_price: number;
88
-
89
- /**
90
- * Currency code
91
- * @example USD
92
- */
93
- currency_code: string;
94
-
95
- /**
96
- * Relevance as a percent: 0 <= relevance <= 1
97
- * @example 0.9
98
- */
99
- relevance?: number;
100
-
101
- /**
102
- * Whether the domain supports privacy
103
- */
104
- supports_privacy?: boolean;
105
-
106
- /**
107
- * The domain vendor
108
- */
109
- vendor?: string;
110
-
111
- /**
112
- * Reasons for suggestion the domain
113
- * @example [ "exact-match" ]
114
- */
115
- match_reasons?: readonly string[];
116
-
117
- /**
118
- * The product ID
119
- */
120
- product_id?: number;
121
-
122
- /**
123
- * The product slug
124
- */
125
- product_slug?: string;
126
-
127
- /**
128
- * Whether the domain is free
129
- */
130
- is_free?: boolean;
131
-
132
- /**
133
- * Whether the domain requires HSTS
134
- */
135
- hsts_required?: boolean;
136
-
137
- /**
138
- * Whether the domain requires to show the notice for .gay tld
139
- */
140
- is_dot_gay_notice_required?: boolean;
141
-
142
- /**
143
- * Whether the domain is unavailable
144
- */
145
- unavailable: boolean;
146
-
147
- isRecommended?: boolean;
148
- isBestAlternative?: boolean;
149
- is_premium?: boolean;
150
- }
151
- export interface DomainCategory {
152
- /**
153
- * The domain category title
154
- */
155
- title: string;
156
-
157
- /**
158
- * The domain category slug
159
- */
160
- slug: string;
161
-
162
- /**
163
- * The domain category tier
164
- */
165
- tier: number | null;
166
- }
167
-
168
- export interface DomainAvailability {
169
- /**
170
- * The domain name the availability was checked for.
171
- */
172
- domain_name: string;
173
-
174
- /**
175
- * The mappability status of the domain.
176
- */
177
- mappable: string;
178
-
179
- /**
180
- * The availability status of the domain.
181
- */
182
- status: string;
183
-
184
- /**
185
- * Whether the domain supports privacy.
186
- */
187
- supports_privacy: boolean;
188
-
189
- /**
190
- * ID of the product
191
- */
192
- product_id?: number;
193
-
194
- /**
195
- * The product slug
196
- */
197
- product_slug?: string;
198
-
199
- /**
200
- * Rendered cost with currency
201
- * @example "€15.00"
202
- */
203
- cost?: string;
204
-
205
- /**
206
- * Vendor
207
- */
208
- vendor?: string;
209
-
210
- /**
211
- * Whether the domain requires HSTS
212
- */
213
- hsts_required?: boolean;
214
-
215
- /**
216
- * Whether the domain requires to show the notice for .gay tld
217
- */
218
- is_dot_gay_notice_required?: boolean;
219
- }
220
-
221
- export type TimestampMS = ReturnType< typeof Date.now >;
222
-
223
- export type DomainSuggestions = Record< string, DomainSuggestion[] | undefined >;
224
-
225
- export interface DomainSuggestionState {
226
- /**
227
- * The state of the DomainSuggestions e.g. pending, failure etc
228
- */
229
- state: DataStatus;
230
-
231
- /**
232
- * Domain suggestion data typically returned from the API
233
- */
234
- data: DomainSuggestions;
235
-
236
- /**
237
- * Error message
238
- */
239
- errorMessage: string | null;
240
-
241
- /**
242
- * Timestamp from last updated attempt
243
- */
244
- lastUpdated: TimestampMS;
245
-
246
- /**
247
- * Pending timestamp
248
- */
249
- pendingSince: TimestampMS | undefined;
250
- }
251
-
252
- export type DomainAvailabilities = Record< string, DomainAvailability | undefined >;
253
-
254
- export type DomainSuggestionSelectorOptions = Partial< Exclude< DomainSuggestionQuery, 'query' > >;
@@ -1,50 +0,0 @@
1
- import { formatCurrency } from '@automattic/number-formatters';
2
- import deterministicStringify from 'fast-json-stable-stringify';
3
- import type { DomainSuggestionQuery, DomainSuggestionSelectorOptions } from './types';
4
-
5
- /**
6
- * Stable transform to an object key for storage and access.
7
- */
8
- export const stringifyDomainQueryObject: ( q: DomainSuggestionQuery ) => string =
9
- deterministicStringify;
10
-
11
- /**
12
- * Formats the domain suggestion price according to 'format-currency' package rules
13
- * We use this for consistency in prices formats across plans and domains
14
- * @param price the domain suggestion raw price
15
- * @param currencyCode the currency code to be used when formatting price
16
- */
17
- export function getFormattedPrice( price: number, currencyCode: string ): string {
18
- return formatCurrency( price, currencyCode, {
19
- stripZeros: true,
20
- } ) as string;
21
- }
22
-
23
- /**
24
- * Normalize domain query
25
- *
26
- * It's important to have a consistent, reproduceable representation of a domains query so that the result can be
27
- * stored and retrieved.
28
- * @param search Domain search string
29
- * @param queryOptions Optional paramaters for the query
30
- * @returns Normalized query object
31
- */
32
- export function normalizeDomainSuggestionQuery(
33
- search: string,
34
- queryOptions: DomainSuggestionSelectorOptions
35
- ): DomainSuggestionQuery {
36
- return {
37
- // Defaults
38
- include_wordpressdotcom: queryOptions.only_wordpressdotcom || false,
39
- include_dotblogsubdomain: false,
40
- only_wordpressdotcom: false,
41
- quantity: 5,
42
- vendor: 'variation2_front',
43
-
44
- // Merge options
45
- ...queryOptions,
46
-
47
- // Add the search query
48
- query: search.trim().toLocaleLowerCase(),
49
- };
50
- }