@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.
- package/CHANGELOG.md +14 -1
- package/dist/cjs/contextual-help/admin-sections.js +1 -1
- package/dist/cjs/contextual-help/admin-sections.js.map +1 -1
- package/dist/cjs/help-center/actions.js +79 -49
- package/dist/cjs/help-center/actions.js.map +1 -1
- package/dist/cjs/help-center/reducer.js +19 -10
- package/dist/cjs/help-center/reducer.js.map +1 -1
- package/dist/cjs/help-center/resolvers.js +2 -1
- package/dist/cjs/help-center/resolvers.js.map +1 -1
- package/dist/cjs/help-center/selectors.js +7 -5
- package/dist/cjs/help-center/selectors.js.map +1 -1
- package/dist/cjs/index.js +1 -4
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/onboard/actions.js +11 -1
- package/dist/cjs/onboard/actions.js.map +1 -1
- package/dist/cjs/onboard/reducer.js +23 -1
- package/dist/cjs/onboard/reducer.js.map +1 -1
- package/dist/cjs/onboard/selectors.js +5 -1
- package/dist/cjs/onboard/selectors.js.map +1 -1
- package/dist/cjs/plans/queries/use-plans.js +20 -1
- package/dist/cjs/plans/queries/use-plans.js.map +1 -1
- package/dist/cjs/purchases/lib/assembler.js +6 -16
- package/dist/cjs/purchases/lib/assembler.js.map +1 -1
- package/dist/cjs/site/types.js.map +1 -1
- package/dist/esm/contextual-help/admin-sections.js +1 -1
- package/dist/esm/contextual-help/admin-sections.js.map +1 -1
- package/dist/esm/help-center/actions.js +74 -46
- package/dist/esm/help-center/actions.js.map +1 -1
- package/dist/esm/help-center/reducer.js +19 -10
- package/dist/esm/help-center/reducer.js.map +1 -1
- package/dist/esm/help-center/resolvers.js +3 -2
- package/dist/esm/help-center/resolvers.js.map +1 -1
- package/dist/esm/help-center/selectors.js +3 -2
- package/dist/esm/help-center/selectors.js.map +1 -1
- package/dist/esm/index.js +1 -3
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/onboard/actions.js +8 -0
- package/dist/esm/onboard/actions.js.map +1 -1
- package/dist/esm/onboard/reducer.js +20 -0
- package/dist/esm/onboard/reducer.js.map +1 -1
- package/dist/esm/onboard/selectors.js +2 -0
- package/dist/esm/onboard/selectors.js.map +1 -1
- package/dist/esm/plans/queries/use-plans.js +20 -1
- package/dist/esm/plans/queries/use-plans.js.map +1 -1
- package/dist/esm/purchases/lib/assembler.js +6 -16
- package/dist/esm/purchases/lib/assembler.js.map +1 -1
- package/dist/esm/site/types.js.map +1 -1
- package/dist/tsconfig-cjs.tsbuildinfo +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/types/help-center/actions.d.ts +30 -14
- package/dist/types/help-center/actions.d.ts.map +1 -1
- package/dist/types/help-center/reducer.d.ts +6 -5
- package/dist/types/help-center/reducer.d.ts.map +1 -1
- package/dist/types/help-center/resolvers.d.ts +16 -8
- package/dist/types/help-center/resolvers.d.ts.map +1 -1
- package/dist/types/help-center/selectors.d.ts +3 -2
- package/dist/types/help-center/selectors.d.ts.map +1 -1
- package/dist/types/help-center/types.d.ts +1 -0
- package/dist/types/help-center/types.d.ts.map +1 -1
- package/dist/types/index.d.ts +473 -43
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/onboard/actions.d.ts +14 -2
- package/dist/types/onboard/actions.d.ts.map +1 -1
- package/dist/types/onboard/reducer.d.ts +7 -1
- package/dist/types/onboard/reducer.d.ts.map +1 -1
- package/dist/types/onboard/selectors.d.ts +6 -2
- package/dist/types/onboard/selectors.d.ts.map +1 -1
- package/dist/types/onboard/types.d.ts +1 -1
- package/dist/types/onboard/types.d.ts.map +1 -1
- package/dist/types/plans/queries/use-plans.d.ts.map +1 -1
- package/dist/types/purchases/lib/assembler.d.ts +3 -3
- package/dist/types/purchases/lib/assembler.d.ts.map +1 -1
- package/dist/types/purchases/types.d.ts +3 -109
- package/dist/types/purchases/types.d.ts.map +1 -1
- package/dist/types/queries/use-all-domains-query.d.ts +1 -1
- package/dist/types/queries/use-all-domains-query.d.ts.map +1 -1
- package/dist/types/queries/use-site-domains-query.d.ts +1 -1
- package/dist/types/queries/use-site-domains-query.d.ts.map +1 -1
- package/dist/types/queries/use-site-query.d.ts +1 -1
- package/dist/types/queries/use-site-query.d.ts.map +1 -1
- package/dist/types/reader/index.d.ts +472 -40
- package/dist/types/reader/index.d.ts.map +1 -1
- package/dist/types/reader/queries/use-pending-post-subscriptions-query.d.ts +75 -7
- package/dist/types/reader/queries/use-pending-post-subscriptions-query.d.ts.map +1 -1
- package/dist/types/reader/queries/use-pending-site-subscriptions-query.d.ts +75 -7
- package/dist/types/reader/queries/use-pending-site-subscriptions-query.d.ts.map +1 -1
- package/dist/types/reader/queries/use-post-subscriptions-query.d.ts +143 -13
- package/dist/types/reader/queries/use-post-subscriptions-query.d.ts.map +1 -1
- package/dist/types/reader/queries/use-site-subscriptions-query.d.ts +103 -13
- package/dist/types/reader/queries/use-site-subscriptions-query.d.ts.map +1 -1
- package/dist/types/site/types.d.ts +2 -0
- package/dist/types/site/types.d.ts.map +1 -1
- package/dist/types/user/actions.d.ts +1 -1
- package/dist/types/user/reducer.d.ts +1 -1
- package/dist/types/user/resolvers.d.ts +2 -2
- package/dist/types/user/selectors.d.ts +2 -2
- package/dist/types/user/selectors.d.ts.map +1 -1
- package/dist/types/user/types.d.ts +2 -33
- package/dist/types/user/types.d.ts.map +1 -1
- package/package.json +4 -8
- package/src/contextual-help/admin-sections.ts +1 -1
- package/src/help-center/actions.ts +85 -50
- package/src/help-center/reducer.ts +27 -15
- package/src/help-center/resolvers.ts +15 -8
- package/src/help-center/selectors.ts +4 -2
- package/src/help-center/types.ts +1 -0
- package/src/index.ts +0 -3
- package/src/onboard/actions.ts +13 -1
- package/src/onboard/reducer.ts +26 -1
- package/src/onboard/selectors.ts +2 -0
- package/src/onboard/types.ts +1 -1
- package/src/plans/queries/use-plans.ts +29 -1
- package/src/purchases/lib/assembler.ts +10 -25
- package/src/purchases/types.ts +4 -116
- package/src/site/types.ts +2 -0
- package/src/user/types.ts +2 -38
- package/dist/cjs/domain-suggestions/actions.js +0 -33
- package/dist/cjs/domain-suggestions/actions.js.map +0 -1
- package/dist/cjs/domain-suggestions/constants.js +0 -12
- package/dist/cjs/domain-suggestions/constants.js.map +0 -1
- package/dist/cjs/domain-suggestions/index.js +0 -25
- package/dist/cjs/domain-suggestions/index.js.map +0 -1
- package/dist/cjs/domain-suggestions/queries.js +0 -78
- package/dist/cjs/domain-suggestions/queries.js.map +0 -1
- package/dist/cjs/domain-suggestions/reducer.js +0 -65
- package/dist/cjs/domain-suggestions/reducer.js.map +0 -1
- package/dist/cjs/domain-suggestions/resolvers.js +0 -91
- package/dist/cjs/domain-suggestions/resolvers.js.map +0 -1
- package/dist/cjs/domain-suggestions/selectors.js +0 -58
- package/dist/cjs/domain-suggestions/selectors.js.map +0 -1
- package/dist/cjs/domain-suggestions/types.js +0 -3
- package/dist/cjs/domain-suggestions/types.js.map +0 -1
- package/dist/cjs/domain-suggestions/utils.js +0 -47
- package/dist/cjs/domain-suggestions/utils.js.map +0 -1
- package/dist/esm/domain-suggestions/actions.js +0 -25
- package/dist/esm/domain-suggestions/actions.js.map +0 -1
- package/dist/esm/domain-suggestions/constants.js +0 -9
- package/dist/esm/domain-suggestions/constants.js.map +0 -1
- package/dist/esm/domain-suggestions/index.js +0 -20
- package/dist/esm/domain-suggestions/index.js.map +0 -1
- package/dist/esm/domain-suggestions/queries.js +0 -72
- package/dist/esm/domain-suggestions/queries.js.map +0 -1
- package/dist/esm/domain-suggestions/reducer.js +0 -61
- package/dist/esm/domain-suggestions/reducer.js.map +0 -1
- package/dist/esm/domain-suggestions/resolvers.js +0 -84
- package/dist/esm/domain-suggestions/resolvers.js.map +0 -1
- package/dist/esm/domain-suggestions/selectors.js +0 -47
- package/dist/esm/domain-suggestions/selectors.js.map +0 -1
- package/dist/esm/domain-suggestions/types.js +0 -2
- package/dist/esm/domain-suggestions/types.js.map +0 -1
- package/dist/esm/domain-suggestions/utils.js +0 -41
- package/dist/esm/domain-suggestions/utils.js.map +0 -1
- package/dist/types/domain-suggestions/actions.d.ts +0 -27
- package/dist/types/domain-suggestions/actions.d.ts.map +0 -1
- package/dist/types/domain-suggestions/constants.d.ts +0 -8
- package/dist/types/domain-suggestions/constants.d.ts.map +0 -1
- package/dist/types/domain-suggestions/index.d.ts +0 -10
- package/dist/types/domain-suggestions/index.d.ts.map +0 -1
- package/dist/types/domain-suggestions/queries.d.ts +0 -323
- package/dist/types/domain-suggestions/queries.d.ts.map +0 -1
- package/dist/types/domain-suggestions/reducer.d.ts +0 -16
- package/dist/types/domain-suggestions/reducer.d.ts.map +0 -1
- package/dist/types/domain-suggestions/resolvers.d.ts +0 -39
- package/dist/types/domain-suggestions/resolvers.d.ts.map +0 -1
- package/dist/types/domain-suggestions/selectors.d.ts +0 -18
- package/dist/types/domain-suggestions/selectors.d.ts.map +0 -1
- package/dist/types/domain-suggestions/types.d.ts +0 -206
- package/dist/types/domain-suggestions/types.d.ts.map +0 -1
- package/dist/types/domain-suggestions/utils.d.ts +0 -23
- package/dist/types/domain-suggestions/utils.d.ts.map +0 -1
- package/src/domain-suggestions/actions.ts +0 -51
- package/src/domain-suggestions/constants.ts +0 -8
- package/src/domain-suggestions/index.ts +0 -22
- package/src/domain-suggestions/queries.ts +0 -85
- package/src/domain-suggestions/reducer.ts +0 -77
- package/src/domain-suggestions/resolvers.ts +0 -110
- package/src/domain-suggestions/selectors.ts +0 -86
- package/src/domain-suggestions/test/reducer.ts +0 -105
- package/src/domain-suggestions/test/selectors.ts +0 -127
- package/src/domain-suggestions/types.ts +0 -254
- 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
|
-
}
|