@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
package/src/purchases/types.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { PriceTierEntry } from '@automattic/calypso-products';
|
|
2
2
|
|
|
3
3
|
export interface Purchase {
|
|
4
|
-
active?: boolean;
|
|
5
4
|
amount: number;
|
|
6
5
|
attachedToPurchaseId: number;
|
|
7
6
|
billPeriodDays: number;
|
|
@@ -11,7 +10,6 @@ export interface Purchase {
|
|
|
11
10
|
asyncPendingPaymentBlockIsSet: boolean;
|
|
12
11
|
canExplicitRenew: boolean;
|
|
13
12
|
canReenableAutoRenewal: boolean;
|
|
14
|
-
costToUnbundle: number;
|
|
15
13
|
costToUnbundleText: string;
|
|
16
14
|
currencyCode: string;
|
|
17
15
|
currencySymbol: string;
|
|
@@ -29,7 +27,6 @@ export interface Purchase {
|
|
|
29
27
|
domain: string;
|
|
30
28
|
|
|
31
29
|
domainRegistrationAgreementUrl: string | null;
|
|
32
|
-
error: null;
|
|
33
30
|
expiryDate: string;
|
|
34
31
|
expiryStatus: string;
|
|
35
32
|
iapPurchaseManagementLink: string | null;
|
|
@@ -71,7 +68,6 @@ export interface Purchase {
|
|
|
71
68
|
productSlug: string;
|
|
72
69
|
productType: string;
|
|
73
70
|
purchaseRenewalQuantity: number | null;
|
|
74
|
-
purchaserId?: number;
|
|
75
71
|
|
|
76
72
|
/**
|
|
77
73
|
* The refund amount for the purchase, not including bundled domains, as a
|
|
@@ -92,7 +88,7 @@ export interface Purchase {
|
|
|
92
88
|
*/
|
|
93
89
|
refundInteger: number;
|
|
94
90
|
|
|
95
|
-
refundOptions: RefundOptions | null;
|
|
91
|
+
refundOptions: RefundOptions[] | null;
|
|
96
92
|
refundPeriodInDays: number;
|
|
97
93
|
|
|
98
94
|
/**
|
|
@@ -162,9 +158,6 @@ export interface Purchase {
|
|
|
162
158
|
userId: number;
|
|
163
159
|
userIsOwner?: boolean;
|
|
164
160
|
partnerKeyId: number | undefined;
|
|
165
|
-
tagLine: string;
|
|
166
|
-
taxAmount: number | string | undefined;
|
|
167
|
-
taxText: string | undefined;
|
|
168
161
|
|
|
169
162
|
/**
|
|
170
163
|
* The coupon code that will automatically apply on the next renewal.
|
|
@@ -175,6 +168,8 @@ export interface Purchase {
|
|
|
175
168
|
* Example: If the discount is 10%, this will have the value `10`.
|
|
176
169
|
*/
|
|
177
170
|
autoRenewCouponDiscountPercentage: number | null;
|
|
171
|
+
|
|
172
|
+
isJetpackPlanOrProduct: boolean;
|
|
178
173
|
}
|
|
179
174
|
|
|
180
175
|
export interface PurchasePriceTier {
|
|
@@ -191,114 +186,7 @@ export interface RawPurchasePriceTierEntry extends PriceTierEntry {
|
|
|
191
186
|
maximum_price_monthly_display: never;
|
|
192
187
|
}
|
|
193
188
|
|
|
194
|
-
export
|
|
195
|
-
ID: number | string;
|
|
196
|
-
active: boolean;
|
|
197
|
-
amount: number | string;
|
|
198
|
-
attached_to_purchase_id: number | string;
|
|
199
|
-
auto_renew_coupon_code: string | null;
|
|
200
|
-
auto_renew_coupon_discount_percentage: number | null;
|
|
201
|
-
bill_period_days: number | string;
|
|
202
|
-
bill_period_label: string;
|
|
203
|
-
most_recent_renew_date: string;
|
|
204
|
-
can_disable_auto_renew: boolean;
|
|
205
|
-
can_reenable_auto_renewal: boolean;
|
|
206
|
-
async_pending_payment_block_is_set: boolean;
|
|
207
|
-
can_explicit_renew: boolean;
|
|
208
|
-
cost_to_unbundle: undefined | number | string;
|
|
209
|
-
cost_to_unbundle_display: undefined | string;
|
|
210
|
-
price_text: string;
|
|
211
|
-
price_tier_list?: Array< RawPurchasePriceTierEntry >;
|
|
212
|
-
currency_code: string;
|
|
213
|
-
currency_symbol: string;
|
|
214
|
-
description: string;
|
|
215
|
-
domain: string;
|
|
216
|
-
domain_registration_agreement_url: string | undefined;
|
|
217
|
-
blog_created_date: string;
|
|
218
|
-
expiry_date: string;
|
|
219
|
-
expiry_status: string;
|
|
220
|
-
iap_purchase_management_link: string | null;
|
|
221
|
-
included_domain: string;
|
|
222
|
-
included_domain_purchase_amount: number;
|
|
223
|
-
introductory_offer: RawPurchaseIntroductoryOffer | null;
|
|
224
|
-
is_cancelable: boolean;
|
|
225
|
-
is_domain: boolean;
|
|
226
|
-
is_domain_registration: boolean;
|
|
227
|
-
is_hundred_year_domain: boolean;
|
|
228
|
-
is_locked: boolean;
|
|
229
|
-
is_iap_purchase: boolean;
|
|
230
|
-
is_rechargable: boolean;
|
|
231
|
-
is_refundable: boolean;
|
|
232
|
-
is_renewable: boolean;
|
|
233
|
-
is_renewal: boolean;
|
|
234
|
-
is_woo_express_trial: boolean;
|
|
235
|
-
meta: string | undefined;
|
|
236
|
-
ownership_id: number | undefined;
|
|
237
|
-
partner_name: string | undefined;
|
|
238
|
-
partner_slug: string | undefined;
|
|
239
|
-
partner_type: string | undefined;
|
|
240
|
-
partner_key_id: number | undefined;
|
|
241
|
-
payment_name: string;
|
|
242
|
-
payment_type:
|
|
243
|
-
| 'credit_card'
|
|
244
|
-
| 'paypal_direct'
|
|
245
|
-
| 'paypal'
|
|
246
|
-
| 'emergent-paywall'
|
|
247
|
-
| 'brazil-tef'
|
|
248
|
-
| string;
|
|
249
|
-
payment_card_display_brand: string | null;
|
|
250
|
-
payment_country_name: string;
|
|
251
|
-
payment_country_code: string | null;
|
|
252
|
-
stored_details_id: string | null;
|
|
253
|
-
pending_transfer: boolean;
|
|
254
|
-
product_id: number | string;
|
|
255
|
-
product_name: string;
|
|
256
|
-
product_slug: string;
|
|
257
|
-
product_type: string;
|
|
258
|
-
product_display_price: string;
|
|
259
|
-
price_integer: number;
|
|
260
|
-
purchaser_id?: number;
|
|
261
|
-
total_refund_amount: number | undefined;
|
|
262
|
-
total_refund_currency: string;
|
|
263
|
-
total_refund_integer: number;
|
|
264
|
-
total_refund_text: string;
|
|
265
|
-
refund_amount: number;
|
|
266
|
-
refund_integer: number;
|
|
267
|
-
refund_text: string;
|
|
268
|
-
refund_currency_symbol: string;
|
|
269
|
-
refund_options: RefundOptions | null;
|
|
270
|
-
refund_period_in_days: number;
|
|
271
|
-
regular_price_text: string;
|
|
272
|
-
regular_price_integer: number;
|
|
273
|
-
renew_date: string;
|
|
274
|
-
sale_amount: number | undefined;
|
|
275
|
-
sale_amount_integer: number | undefined;
|
|
276
|
-
blog_id: number | string;
|
|
277
|
-
blogname: string;
|
|
278
|
-
site_slug?: string;
|
|
279
|
-
subscribed_date: string;
|
|
280
|
-
subscription_status: 'active' | 'inactive';
|
|
281
|
-
tag_line: string;
|
|
282
|
-
tax_amount: number | string | undefined;
|
|
283
|
-
tax_text: string | undefined;
|
|
284
|
-
renewal_price_tier_usage_quantity: number | undefined | null;
|
|
285
|
-
user_id: number | string;
|
|
286
|
-
auto_renew: '1' | '0' | null;
|
|
287
|
-
payment_card_id: number | string | undefined;
|
|
288
|
-
payment_card_type: string | undefined;
|
|
289
|
-
payment_card_processor: string | undefined;
|
|
290
|
-
payment_details: string | undefined;
|
|
291
|
-
payment_expiry: string | undefined;
|
|
292
|
-
}
|
|
293
|
-
|
|
294
|
-
export type RawPurchaseCreditCard = RawPurchase & {
|
|
295
|
-
payment_type: 'credit_card';
|
|
296
|
-
payment_card_type: string;
|
|
297
|
-
payment_card_display_brand: string | null;
|
|
298
|
-
payment_card_processor: string;
|
|
299
|
-
payment_details: string | number;
|
|
300
|
-
payment_expiry: string;
|
|
301
|
-
};
|
|
189
|
+
export type { RawPurchase } from '@automattic/api-core';
|
|
302
190
|
|
|
303
191
|
export interface RefundOptions {
|
|
304
192
|
to_product_id: number;
|
package/src/site/types.ts
CHANGED
|
@@ -133,6 +133,7 @@ export interface SiteDetails {
|
|
|
133
133
|
is_deleted?: boolean;
|
|
134
134
|
is_vip?: boolean;
|
|
135
135
|
is_wpcom_atomic?: boolean;
|
|
136
|
+
is_wpcom_flex?: boolean;
|
|
136
137
|
is_wpcom_staging_site?: boolean;
|
|
137
138
|
is_a4a_client?: boolean;
|
|
138
139
|
is_a4a_dev_site?: boolean;
|
|
@@ -258,6 +259,7 @@ export interface SiteDetailsOptions {
|
|
|
258
259
|
is_automated_transfer?: boolean;
|
|
259
260
|
is_cloud_eligible?: boolean;
|
|
260
261
|
is_difm_lite_in_progress?: boolean;
|
|
262
|
+
is_summer_special_2025?: boolean;
|
|
261
263
|
is_domain_only?: boolean;
|
|
262
264
|
is_mapped_domain?: boolean;
|
|
263
265
|
is_pending_plan?: boolean;
|
package/src/user/types.ts
CHANGED
|
@@ -1,44 +1,8 @@
|
|
|
1
1
|
import * as selectors from './selectors';
|
|
2
2
|
import type { ActionCreators } from './actions';
|
|
3
3
|
import type { SelectFromMap } from '../mapped-types';
|
|
4
|
-
|
|
5
|
-
ID: number;
|
|
6
|
-
display_name: string;
|
|
7
|
-
username: string;
|
|
8
|
-
email: string;
|
|
9
|
-
/**
|
|
10
|
-
* The user's locale slug, e.g. `es`.
|
|
11
|
-
*/
|
|
12
|
-
language: string;
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
* The bootstraped user's locale slug, e.g. `es`.
|
|
16
|
-
* @deprecated Use `language` instead.
|
|
17
|
-
*/
|
|
18
|
-
localeSlug?: string;
|
|
19
|
-
|
|
20
|
-
/**
|
|
21
|
-
* The user's locale variant, e.g. `es-mx`.
|
|
22
|
-
* If there is no variant, `""` empty string is returned.
|
|
23
|
-
*/
|
|
24
|
-
locale_variant: string;
|
|
25
|
-
|
|
26
|
-
/**
|
|
27
|
-
* The bootstrapped user's locale variant, e.g. `es-mx`.
|
|
28
|
-
* @deprecated Use `locale_variant` instead.
|
|
29
|
-
*/
|
|
30
|
-
localeVariant?: string;
|
|
31
|
-
|
|
32
|
-
/**
|
|
33
|
-
* The user's existing sites count.
|
|
34
|
-
*/
|
|
35
|
-
site_count: number;
|
|
36
|
-
|
|
37
|
-
/**
|
|
38
|
-
* The subkey for Subscription Management
|
|
39
|
-
*/
|
|
40
|
-
subscriptionManagementSubkey?: string;
|
|
41
|
-
}
|
|
4
|
+
import type { User } from '@automattic/api-core';
|
|
42
5
|
|
|
6
|
+
export type CurrentUser = User;
|
|
43
7
|
export type UserSelect = SelectFromMap< typeof selectors >;
|
|
44
8
|
export type UserActions = ActionCreators;
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.receiveDomainSuggestionsError = exports.receiveDomainSuggestionsSuccess = exports.receiveDomainAvailability = exports.fetchDomainSuggestions = exports.receiveCategories = void 0;
|
|
4
|
-
const receiveCategories = (categories) => ({
|
|
5
|
-
type: 'RECEIVE_CATEGORIES',
|
|
6
|
-
categories,
|
|
7
|
-
});
|
|
8
|
-
exports.receiveCategories = receiveCategories;
|
|
9
|
-
const fetchDomainSuggestions = () => ({
|
|
10
|
-
type: 'FETCH_DOMAIN_SUGGESTIONS',
|
|
11
|
-
timeStamp: Date.now(),
|
|
12
|
-
});
|
|
13
|
-
exports.fetchDomainSuggestions = fetchDomainSuggestions;
|
|
14
|
-
const receiveDomainAvailability = (domainName, availability) => ({
|
|
15
|
-
type: 'RECEIVE_DOMAIN_AVAILABILITY',
|
|
16
|
-
domainName,
|
|
17
|
-
availability,
|
|
18
|
-
});
|
|
19
|
-
exports.receiveDomainAvailability = receiveDomainAvailability;
|
|
20
|
-
const receiveDomainSuggestionsSuccess = (queryObject, suggestions) => ({
|
|
21
|
-
type: 'RECEIVE_DOMAIN_SUGGESTIONS_SUCCESS',
|
|
22
|
-
queryObject,
|
|
23
|
-
suggestions,
|
|
24
|
-
timeStamp: Date.now(),
|
|
25
|
-
});
|
|
26
|
-
exports.receiveDomainSuggestionsSuccess = receiveDomainSuggestionsSuccess;
|
|
27
|
-
const receiveDomainSuggestionsError = (errorMessage) => ({
|
|
28
|
-
type: 'RECEIVE_DOMAIN_SUGGESTIONS_ERROR',
|
|
29
|
-
errorMessage,
|
|
30
|
-
timeStamp: Date.now(),
|
|
31
|
-
});
|
|
32
|
-
exports.receiveDomainSuggestionsError = receiveDomainSuggestionsError;
|
|
33
|
-
//# sourceMappingURL=actions.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"actions.js","sourceRoot":"","sources":["../../../src/domain-suggestions/actions.ts"],"names":[],"mappings":";;;AAOO,MAAM,iBAAiB,GAAG,CAAE,UAA4B,EAAG,EAAE,CACnE,CAAE;IACD,IAAI,EAAE,oBAAoB;IAC1B,UAAU;CACV,CAAW,CAAC;AAJD,QAAA,iBAAiB,qBAIhB;AAEP,MAAM,sBAAsB,GAAG,GAAG,EAAE,CAC1C,CAAE;IACD,IAAI,EAAE,0BAA0B;IAChC,SAAS,EAAE,IAAI,CAAC,GAAG,EAAE;CACrB,CAAW,CAAC;AAJD,QAAA,sBAAsB,0BAIrB;AAEP,MAAM,yBAAyB,GAAG,CAAE,UAAkB,EAAE,YAAgC,EAAG,EAAE,CACnG,CAAE;IACD,IAAI,EAAE,6BAA6B;IACnC,UAAU;IACV,YAAY;CACZ,CAAW,CAAC;AALD,QAAA,yBAAyB,6BAKxB;AAEP,MAAM,+BAA+B,GAAG,CAC9C,WAAkC,EAClC,WAA2C,EAC1C,EAAE,CACH,CAAE;IACD,IAAI,EAAE,oCAAoC;IAC1C,WAAW;IACX,WAAW;IACX,SAAS,EAAE,IAAI,CAAC,GAAG,EAAE;CACrB,CAAW,CAAC;AATD,QAAA,+BAA+B,mCAS9B;AAEP,MAAM,6BAA6B,GAAG,CAAE,YAAoB,EAAG,EAAE,CACvE,CAAE;IACD,IAAI,EAAE,kCAAkC;IACxC,YAAY;IACZ,SAAS,EAAE,IAAI,CAAC,GAAG,EAAE;CACrB,CAAW,CAAC;AALD,QAAA,6BAA6B,iCAK5B"}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.DataStatus = exports.STORE_KEY = void 0;
|
|
4
|
-
exports.STORE_KEY = 'automattic/domains/suggestions';
|
|
5
|
-
var DataStatus;
|
|
6
|
-
(function (DataStatus) {
|
|
7
|
-
DataStatus["Failure"] = "failure";
|
|
8
|
-
DataStatus["Pending"] = "pending";
|
|
9
|
-
DataStatus["Success"] = "success";
|
|
10
|
-
DataStatus["Uninitialized"] = "uninitialized";
|
|
11
|
-
})(DataStatus || (exports.DataStatus = DataStatus = {}));
|
|
12
|
-
//# sourceMappingURL=constants.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../src/domain-suggestions/constants.ts"],"names":[],"mappings":";;;AAAa,QAAA,SAAS,GAAG,gCAAgC,CAAC;AAE1D,IAAY,UAKX;AALD,WAAY,UAAU;IACrB,iCAAmB,CAAA;IACnB,iCAAmB,CAAA;IACnB,iCAAmB,CAAA;IACnB,6CAA+B,CAAA;AAChC,CAAC,EALW,UAAU,0BAAV,UAAU,QAKrB"}
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.store = exports.getFormattedPrice = void 0;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
|
-
const data_1 = require("@wordpress/data");
|
|
6
|
-
const wpcom_request_controls_1 = require("../wpcom-request-controls");
|
|
7
|
-
const actions = tslib_1.__importStar(require("./actions"));
|
|
8
|
-
const constants_1 = require("./constants");
|
|
9
|
-
const reducer_1 = tslib_1.__importDefault(require("./reducer"));
|
|
10
|
-
const resolvers = tslib_1.__importStar(require("./resolvers"));
|
|
11
|
-
const selectors = tslib_1.__importStar(require("./selectors"));
|
|
12
|
-
tslib_1.__exportStar(require("./types"), exports);
|
|
13
|
-
tslib_1.__exportStar(require("./constants"), exports);
|
|
14
|
-
tslib_1.__exportStar(require("./queries"), exports);
|
|
15
|
-
var utils_1 = require("./utils");
|
|
16
|
-
Object.defineProperty(exports, "getFormattedPrice", { enumerable: true, get: function () { return utils_1.getFormattedPrice; } });
|
|
17
|
-
exports.store = (0, data_1.createReduxStore)(constants_1.STORE_KEY, {
|
|
18
|
-
actions,
|
|
19
|
-
controls: wpcom_request_controls_1.controls,
|
|
20
|
-
reducer: reducer_1.default,
|
|
21
|
-
resolvers,
|
|
22
|
-
selectors,
|
|
23
|
-
});
|
|
24
|
-
(0, data_1.register)(exports.store);
|
|
25
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/domain-suggestions/index.ts"],"names":[],"mappings":";;;;AAAA,0CAA6D;AAC7D,sEAAqD;AACrD,2DAAqC;AACrC,2CAAwC;AACxC,gEAA2C;AAC3C,+DAAyC;AACzC,+DAAyC;AAEzC,kDAAwB;AACxB,sDAA4B;AAC5B,oDAA0B;AAC1B,iCAA4C;AAAnC,0GAAA,iBAAiB,OAAA;AAGb,QAAA,KAAK,GAAG,IAAA,uBAAgB,EAAE,qBAAS,EAAE;IACjD,OAAO;IACP,QAAQ,EAAR,iCAAQ;IACR,OAAO,EAAP,iBAAO;IACP,SAAS;IACT,SAAS;CACT,CAAE,CAAC;AACJ,IAAA,eAAQ,EAAE,aAAK,CAAE,CAAC"}
|
|
@@ -1,78 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.useGetDomainSuggestions = useGetDomainSuggestions;
|
|
4
|
-
exports.useGetWordPressSubdomain = useGetWordPressSubdomain;
|
|
5
|
-
exports.useGetSingleCustomDotComDomainSuggestion = useGetSingleCustomDotComDomainSuggestion;
|
|
6
|
-
const tslib_1 = require("tslib");
|
|
7
|
-
const react_query_1 = require("@tanstack/react-query");
|
|
8
|
-
const qs_1 = require("qs");
|
|
9
|
-
const wpcom_proxy_request_1 = tslib_1.__importDefault(require("wpcom-proxy-request"));
|
|
10
|
-
const utils_1 = require("./utils");
|
|
11
|
-
const STALE_TIME = 1000 * 60 * 5; // 5 minutes
|
|
12
|
-
function useGetDomainSuggestions(search, searchOptions = {}, queryOptions = {}) {
|
|
13
|
-
const queryClient = (0, react_query_1.useQueryClient)();
|
|
14
|
-
const result = (0, react_query_1.useQuery)({
|
|
15
|
-
queryKey: ['domain-suggestions', search, searchOptions],
|
|
16
|
-
queryFn: async () => {
|
|
17
|
-
if (!search) {
|
|
18
|
-
return [];
|
|
19
|
-
}
|
|
20
|
-
const queryObject = (0, utils_1.normalizeDomainSuggestionQuery)(search, searchOptions);
|
|
21
|
-
const suggestions = await (0, wpcom_proxy_request_1.default)({
|
|
22
|
-
apiVersion: '1.1',
|
|
23
|
-
path: '/domains/suggestions',
|
|
24
|
-
query: (0, qs_1.stringify)(queryObject),
|
|
25
|
-
});
|
|
26
|
-
if (!Array.isArray(suggestions)) {
|
|
27
|
-
throw new Error('Invalid response from the server');
|
|
28
|
-
}
|
|
29
|
-
const processedSuggestions = suggestions.map((suggestion) => {
|
|
30
|
-
if (suggestion.unavailable) {
|
|
31
|
-
return suggestion;
|
|
32
|
-
}
|
|
33
|
-
return {
|
|
34
|
-
...suggestion,
|
|
35
|
-
...(suggestion.raw_price &&
|
|
36
|
-
suggestion.currency_code && {
|
|
37
|
-
cost: (0, utils_1.getFormattedPrice)(suggestion.raw_price, suggestion.currency_code),
|
|
38
|
-
}),
|
|
39
|
-
};
|
|
40
|
-
});
|
|
41
|
-
return processedSuggestions;
|
|
42
|
-
},
|
|
43
|
-
enabled: !!search,
|
|
44
|
-
staleTime: STALE_TIME,
|
|
45
|
-
...queryOptions,
|
|
46
|
-
});
|
|
47
|
-
return {
|
|
48
|
-
...result,
|
|
49
|
-
invalidateCache: () => queryClient.invalidateQueries({
|
|
50
|
-
queryKey: ['domain-suggestions', search, searchOptions],
|
|
51
|
-
}),
|
|
52
|
-
};
|
|
53
|
-
}
|
|
54
|
-
/**
|
|
55
|
-
* Returns the expected *.wordpress.com for a given domain name
|
|
56
|
-
*/
|
|
57
|
-
function useGetWordPressSubdomain(paidDomainName) {
|
|
58
|
-
return useGetDomainSuggestions(paidDomainName, {
|
|
59
|
-
quantity: 1,
|
|
60
|
-
include_wordpressdotcom: true,
|
|
61
|
-
include_dotblogsubdomain: false,
|
|
62
|
-
only_wordpressdotcom: false,
|
|
63
|
-
vendor: 'dot',
|
|
64
|
-
});
|
|
65
|
-
}
|
|
66
|
-
/**
|
|
67
|
-
* Returns a custom .com domain suggestion for a given query
|
|
68
|
-
*/
|
|
69
|
-
function useGetSingleCustomDotComDomainSuggestion(query, locale) {
|
|
70
|
-
return useGetDomainSuggestions(query, {
|
|
71
|
-
quantity: 1,
|
|
72
|
-
include_wordpressdotcom: false,
|
|
73
|
-
include_dotblogsubdomain: false,
|
|
74
|
-
locale,
|
|
75
|
-
tlds: ['com'],
|
|
76
|
-
});
|
|
77
|
-
}
|
|
78
|
-
//# sourceMappingURL=queries.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"queries.js","sourceRoot":"","sources":["../../../src/domain-suggestions/queries.ts"],"names":[],"mappings":";;AAQA,0DAkDC;AAKD,4DAQC;AAKD,4FAQC;;AApFD,uDAAiE;AACjE,2BAA+B;AAC/B,sFAAoD;AACpD,mCAA4E;AAG5E,MAAM,UAAU,GAAG,IAAI,GAAG,EAAE,GAAG,CAAC,CAAC,CAAC,YAAY;AAE9C,SAAgB,uBAAuB,CACtC,MAAsB,EACtB,gBAAiD,EAAE,EACnD,YAAY,GAAG,EAAE;IAEjB,MAAM,WAAW,GAAG,IAAA,4BAAc,GAAE,CAAC;IACrC,MAAM,MAAM,GAAG,IAAA,sBAAQ,EAAE;QACxB,QAAQ,EAAE,CAAE,oBAAoB,EAAE,MAAM,EAAE,aAAa,CAAE;QACzD,OAAO,EAAE,KAAK,IAAI,EAAE;YACnB,IAAK,CAAE,MAAM,EAAG,CAAC;gBAChB,OAAO,EAAE,CAAC;YACX,CAAC;YACD,MAAM,WAAW,GAAG,IAAA,sCAA8B,EAAE,MAAM,EAAE,aAAa,CAAE,CAAC;YAE5E,MAAM,WAAW,GAAuB,MAAM,IAAA,6BAAiB,EAAE;gBAChE,UAAU,EAAE,KAAK;gBACjB,IAAI,EAAE,sBAAsB;gBAC5B,KAAK,EAAE,IAAA,cAAS,EAAE,WAAW,CAAE;aAC/B,CAAE,CAAC;YACJ,IAAK,CAAE,KAAK,CAAC,OAAO,CAAE,WAAW,CAAE,EAAG,CAAC;gBACtC,MAAM,IAAI,KAAK,CAA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,CAAC;AACL,CAAC"}
|
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.domainSuggestions = void 0;
|
|
4
|
-
const data_1 = require("@wordpress/data");
|
|
5
|
-
const constants_1 = require("./constants");
|
|
6
|
-
const utils_1 = require("./utils");
|
|
7
|
-
const initialDomainSuggestionState = {
|
|
8
|
-
state: constants_1.DataStatus.Uninitialized,
|
|
9
|
-
data: {},
|
|
10
|
-
errorMessage: null,
|
|
11
|
-
lastUpdated: -Infinity,
|
|
12
|
-
pendingSince: undefined,
|
|
13
|
-
};
|
|
14
|
-
const domainSuggestions = (state = initialDomainSuggestionState, action) => {
|
|
15
|
-
if (action.type === 'FETCH_DOMAIN_SUGGESTIONS') {
|
|
16
|
-
return {
|
|
17
|
-
...state,
|
|
18
|
-
state: constants_1.DataStatus.Pending,
|
|
19
|
-
errorMessage: null,
|
|
20
|
-
pendingSince: action.timeStamp,
|
|
21
|
-
};
|
|
22
|
-
}
|
|
23
|
-
if (action.type === 'RECEIVE_DOMAIN_SUGGESTIONS_SUCCESS') {
|
|
24
|
-
return {
|
|
25
|
-
...state,
|
|
26
|
-
state: constants_1.DataStatus.Success,
|
|
27
|
-
data: {
|
|
28
|
-
...state.data,
|
|
29
|
-
[(0, utils_1.stringifyDomainQueryObject)(action.queryObject)]: action.suggestions,
|
|
30
|
-
},
|
|
31
|
-
errorMessage: null,
|
|
32
|
-
lastUpdated: action.timeStamp,
|
|
33
|
-
pendingSince: undefined,
|
|
34
|
-
};
|
|
35
|
-
}
|
|
36
|
-
if (action.type === 'RECEIVE_DOMAIN_SUGGESTIONS_ERROR') {
|
|
37
|
-
return {
|
|
38
|
-
...state,
|
|
39
|
-
state: constants_1.DataStatus.Failure,
|
|
40
|
-
errorMessage: action.errorMessage,
|
|
41
|
-
lastUpdated: action.timeStamp,
|
|
42
|
-
pendingSince: undefined,
|
|
43
|
-
};
|
|
44
|
-
}
|
|
45
|
-
return state;
|
|
46
|
-
};
|
|
47
|
-
exports.domainSuggestions = domainSuggestions;
|
|
48
|
-
const categories = (state = [], action) => {
|
|
49
|
-
if (action.type === 'RECEIVE_CATEGORIES') {
|
|
50
|
-
return action.categories;
|
|
51
|
-
}
|
|
52
|
-
return state;
|
|
53
|
-
};
|
|
54
|
-
const availability = (state = {}, action) => {
|
|
55
|
-
if (action.type === 'RECEIVE_DOMAIN_AVAILABILITY') {
|
|
56
|
-
return {
|
|
57
|
-
...state,
|
|
58
|
-
[action.domainName]: action.availability,
|
|
59
|
-
};
|
|
60
|
-
}
|
|
61
|
-
return state;
|
|
62
|
-
};
|
|
63
|
-
const reducer = (0, data_1.combineReducers)({ categories, domainSuggestions: exports.domainSuggestions, availability });
|
|
64
|
-
exports.default = reducer;
|
|
65
|
-
//# sourceMappingURL=reducer.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"reducer.js","sourceRoot":"","sources":["../../../src/domain-suggestions/reducer.ts"],"names":[],"mappings":";;;AAAA,0CAAkD;AAClD,2CAAyC;AACzC,mCAAqD;AAKrD,MAAM,4BAA4B,GAA0B;IAC3D,KAAK,EAAE,sBAAU,CAAC,aAAa;IAC/B,IAAI,EAAE,EAAE;IACR,YAAY,EAAE,IAAI;IAClB,WAAW,EAAE,CAAC,QAAQ;IACtB,YAAY,EAAE,SAAS;CACvB,CAAC;AAEK,MAAM,iBAAiB,GAA6C,CAC1E,KAAK,GAAG,4BAA4B,EACpC,MAAM,EACL,EAAE;IACH,IAAK,MAAM,CAAC,IAAI,KAAK,0BAA0B,EAAG,CAAC;QAClD,OAAO;YACN,GAAG,KAAK;YACR,KAAK,EAAE,sBAAU,CAAC,OAAO;YACzB,YAAY,EAAE,IAAI;YAClB,YAAY,EAAE,MAAM,CAAC,SAAS;SAC9B,CAAC;IACH,CAAC;IAED,IAAK,MAAM,CAAC,IAAI,KAAK,oCAAoC,EAAG,CAAC;QAC5D,OAAO;YACN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,kBAAe,OAAO,CAAC"}
|
|
@@ -1,91 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.isAvailable = void 0;
|
|
4
|
-
exports.getCategories = getCategories;
|
|
5
|
-
exports.__internalGetDomainSuggestions = __internalGetDomainSuggestions;
|
|
6
|
-
const tslib_1 = require("tslib");
|
|
7
|
-
const i18n_calypso_1 = require("i18n-calypso");
|
|
8
|
-
const qs_1 = require("qs");
|
|
9
|
-
const validator_1 = tslib_1.__importDefault(require("validator"));
|
|
10
|
-
const wpcom_request_controls_1 = require("../wpcom-request-controls");
|
|
11
|
-
const actions_1 = require("./actions");
|
|
12
|
-
const utils_1 = require("./utils");
|
|
13
|
-
function getAvailabilityURL(domainName) {
|
|
14
|
-
return `https://public-api.wordpress.com/rest/v1.3/domains/${encodeURIComponent(domainName)}/is-available?is_cart_pre_check=true`;
|
|
15
|
-
}
|
|
16
|
-
function suggestionsLackThisFQDN(suggestions, domainName) {
|
|
17
|
-
return (validator_1.default.isFQDN(domainName) &&
|
|
18
|
-
!suggestions.some((s) => s.domain_name.toLowerCase() === domainName));
|
|
19
|
-
}
|
|
20
|
-
const isAvailable = function* isAvailable(domainName) {
|
|
21
|
-
const url = getAvailabilityURL(domainName);
|
|
22
|
-
try {
|
|
23
|
-
const { body } = yield (0, wpcom_request_controls_1.fetchAndParse)(url);
|
|
24
|
-
return (0, actions_1.receiveDomainAvailability)(domainName, body);
|
|
25
|
-
}
|
|
26
|
-
catch {
|
|
27
|
-
// the API returns a status of 'unknown' if it can not accurately determine
|
|
28
|
-
// availability, we will return the same status if the API request fails.
|
|
29
|
-
return (0, actions_1.receiveDomainAvailability)(domainName, {
|
|
30
|
-
domain_name: domainName,
|
|
31
|
-
mappable: 'unknown',
|
|
32
|
-
status: 'unknown',
|
|
33
|
-
supports_privacy: false,
|
|
34
|
-
});
|
|
35
|
-
}
|
|
36
|
-
};
|
|
37
|
-
exports.isAvailable = isAvailable;
|
|
38
|
-
function* getCategories() {
|
|
39
|
-
const { body } = yield (0, wpcom_request_controls_1.fetchAndParse)('https://public-api.wordpress.com/wpcom/v2/onboarding/domains/categories');
|
|
40
|
-
return (0, actions_1.receiveCategories)(body);
|
|
41
|
-
}
|
|
42
|
-
function* __internalGetDomainSuggestions(queryObject) {
|
|
43
|
-
// If normalized search string (`query`) contains no alphanumerics, endpoint 404s
|
|
44
|
-
if (!queryObject.query) {
|
|
45
|
-
return (0, actions_1.receiveDomainSuggestionsError)('Empty query');
|
|
46
|
-
}
|
|
47
|
-
yield (0, actions_1.fetchDomainSuggestions)();
|
|
48
|
-
try {
|
|
49
|
-
const suggestions = yield (0, wpcom_request_controls_1.wpcomRequest)({
|
|
50
|
-
apiVersion: '1.1',
|
|
51
|
-
path: '/domains/suggestions',
|
|
52
|
-
query: (0, qs_1.stringify)(queryObject),
|
|
53
|
-
});
|
|
54
|
-
if (!Array.isArray(suggestions)) {
|
|
55
|
-
// Other internal server errors
|
|
56
|
-
return (0, actions_1.receiveDomainSuggestionsError)((0, i18n_calypso_1.translate)('Invalid response from the server'));
|
|
57
|
-
}
|
|
58
|
-
// if the query is a FQDN and the results don't have it,
|
|
59
|
-
// this implies that the user is searching for an unavailable domain name
|
|
60
|
-
// TODO: query the availability endpoint to find the exact reason why it's unavailable
|
|
61
|
-
// all the possible responses can be found here https://github.com/Automattic/wp-calypso/blob/trunk/client/lib/domains/registration/availability-messages.js#L40-L390
|
|
62
|
-
if (suggestionsLackThisFQDN(suggestions, queryObject.query)) {
|
|
63
|
-
const unavailableSuggestion = {
|
|
64
|
-
domain_name: queryObject.query,
|
|
65
|
-
unavailable: true,
|
|
66
|
-
cost: '',
|
|
67
|
-
raw_price: 0,
|
|
68
|
-
currency_code: '',
|
|
69
|
-
};
|
|
70
|
-
suggestions.unshift(unavailableSuggestion);
|
|
71
|
-
}
|
|
72
|
-
const processedSuggestions = suggestions.map((suggestion) => {
|
|
73
|
-
if (suggestion.unavailable) {
|
|
74
|
-
return suggestion;
|
|
75
|
-
}
|
|
76
|
-
return {
|
|
77
|
-
...suggestion,
|
|
78
|
-
...(suggestion.raw_price &&
|
|
79
|
-
suggestion.currency_code && {
|
|
80
|
-
cost: (0, utils_1.getFormattedPrice)(suggestion.raw_price, suggestion.currency_code),
|
|
81
|
-
}),
|
|
82
|
-
};
|
|
83
|
-
});
|
|
84
|
-
return (0, actions_1.receiveDomainSuggestionsSuccess)(queryObject, processedSuggestions);
|
|
85
|
-
}
|
|
86
|
-
catch (e) {
|
|
87
|
-
// e.g. no connection, or JSON parsing error
|
|
88
|
-
return (0, actions_1.receiveDomainSuggestionsError)(e.message || (0, i18n_calypso_1.translate)('Error while fetching server response'));
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
//# sourceMappingURL=resolvers.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"resolvers.js","sourceRoot":"","sources":["../../../src/domain-suggestions/resolvers.ts"],"names":[],"mappings":";;;AA6CA,sCAKC;AAED,wEAyDC;;AA7GD,+CAAyC;AACzC,2BAA+B;AAC/B,kEAAkC;AAClC,sEAAwE;AACxE,uCAMmB;AACnB,mCAA4C;AAG5C,SAAS,kBAAkB,CAAE,UAAkB;IAC9C,OAAO,sDAAuD,kBAAkB,CAC/E,UAAU,CACT,sCAAsC,CAAC;AAC1C,CAAC;AAED,SAAS,uBAAuB,CAAE,WAA+B,EAAE,UAAkB;IACpF,OAAO,CACN,mBAAS,CAAC,MAAM,CAAE,UAAU,CAAE;QAC9B,CAAE,WAAW,CAAC,IAAI,CAAE,CAAE,CAAC,EAAG,EAAE,CAAC,CAAC,CAAC,WAAW,CAAC,WAAW,EAAE,KAAK,UAAU,CAAE,CACzE,CAAC;AACH,CAAC;AAEM,MAAM,WAAW,GAAG,QAAQ,CAAC,CAAC,WAAW,CAAE,UAAkB;IACnE,MAAM,GAAG,GAAG,kBAAkB,CAAE,UAAU,CAAE,CAAC;IAE7C,IAAI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rK,IAAK,uBAAuB,CAAE,WAAW,EAAE,WAAW,CAAC,KAAK,CAAE,EAAG,CAAC;YACjE,MAAM,qBAAqB,GAAqB;gBAC/C,WAAW,EAAE,WAAW,CAAC,KAAK;gBAC9B,WAAW,EAAE,IAAI;gBACjB,IAAI,EAAE,EAAE;gBACR,SAAS,EAAE,CAAC;gBACZ,aAAa,EAAE,EAAE;aACjB,CAAC;YACF,WAAW,CAAC,OAAO,CAAE,qBAAqB,CAAE,CAAC;QAC9C,CAAC;QAED,MAAM,oBAAoB,GAAG,WAAW,CAAC,GAAG,CAAE,CAAE,UAA4B,EAAG,EAAE;YAChF,IAAK,UAAU,CAAC,WAAW,EAAG,CAAC;gBAC9B,OAAO,UAAU,CAAC;YACnB,CAAC;YACD,OAAO;gBACN,GAAG,UAAU;gBACb,GAAG,CAAE,UAAU,CAAC,SAAS;oBACxB,UAAU,CAAC,aAAa,IAAI;oBAC3B,IAAI,EAAE,IAAA,yBAAiB,EAAE,UAAU,CAAC,SAAS,EAAE,UAAU,CAAC,aAAa,CAAE;iBACzE,CAAE;aACJ,CAAC;QACH,CAAC,CAAE,CAAC;QAEJ,OAAO,IAAA,yCAA+B,EAAE,WAAW,EAAE,oBAAoB,CAAE,CAAC;IAC7E,CAAC;IAAC,OAAQ,CAAC,EAAG,CAAC;QACd,4CAA4C;QAC5C,OAAO,IAAA,uCAA6B,EACjC,CAAY,CAAC,OAAO,IAAM,IAAA,wBAAS,EAAE,sCAAsC,CAAc,CAC3F,CAAC;IACH,CAAC;AACF,CAAC"}
|
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getDomainAvailabilities = exports.isAvailable = exports.__internalGetDomainSuggestions = exports.isLoadingDomainSuggestions = exports.getDomainErrorMessage = exports.getDomainState = exports.getDomainSuggestions = exports.getCategories = void 0;
|
|
4
|
-
const data_1 = require("@wordpress/data");
|
|
5
|
-
const constants_1 = require("./constants");
|
|
6
|
-
const utils_1 = require("./utils");
|
|
7
|
-
const getCategories = (state) => {
|
|
8
|
-
// Sort domain categories by tier, then by title.
|
|
9
|
-
return [
|
|
10
|
-
...state.categories
|
|
11
|
-
.filter(({ tier }) => tier !== null)
|
|
12
|
-
.sort((a, b) => (a > b ? 1 : -1)),
|
|
13
|
-
...state.categories
|
|
14
|
-
.filter(({ tier }) => tier === null)
|
|
15
|
-
.sort((a, b) => a.title.localeCompare(b.title)),
|
|
16
|
-
];
|
|
17
|
-
};
|
|
18
|
-
exports.getCategories = getCategories;
|
|
19
|
-
const getDomainSuggestions = (_state, search, options = {}) => {
|
|
20
|
-
const normalizedQuery = (0, utils_1.normalizeDomainSuggestionQuery)(search, options);
|
|
21
|
-
// We need to go through the `select` store to get the resolver action
|
|
22
|
-
return (0, data_1.select)(constants_1.STORE_KEY).__internalGetDomainSuggestions(normalizedQuery);
|
|
23
|
-
};
|
|
24
|
-
exports.getDomainSuggestions = getDomainSuggestions;
|
|
25
|
-
const getDomainState = (state) => {
|
|
26
|
-
return state.domainSuggestions.state;
|
|
27
|
-
};
|
|
28
|
-
exports.getDomainState = getDomainState;
|
|
29
|
-
const getDomainErrorMessage = (state) => {
|
|
30
|
-
return state.domainSuggestions.errorMessage;
|
|
31
|
-
};
|
|
32
|
-
exports.getDomainErrorMessage = getDomainErrorMessage;
|
|
33
|
-
// TODO: reconcile this function with "Pending" status?
|
|
34
|
-
// It doesn't seem to be used
|
|
35
|
-
const isLoadingDomainSuggestions = (_state, search, options = {}) => {
|
|
36
|
-
const normalizedQuery = (0, utils_1.normalizeDomainSuggestionQuery)(search, options);
|
|
37
|
-
return (0, data_1.select)('core/data').isResolving(constants_1.STORE_KEY, '__internalGetDomainSuggestions', [normalizedQuery]);
|
|
38
|
-
};
|
|
39
|
-
exports.isLoadingDomainSuggestions = isLoadingDomainSuggestions;
|
|
40
|
-
/**
|
|
41
|
-
* Do not use this selector. It is for internal use.
|
|
42
|
-
* @param state Store state
|
|
43
|
-
* @param queryObject Normalized object representing the query
|
|
44
|
-
* @returns suggestions
|
|
45
|
-
*/
|
|
46
|
-
const __internalGetDomainSuggestions = (state, queryObject) => {
|
|
47
|
-
return state.domainSuggestions.data[(0, utils_1.stringifyDomainQueryObject)(queryObject)];
|
|
48
|
-
};
|
|
49
|
-
exports.__internalGetDomainSuggestions = __internalGetDomainSuggestions;
|
|
50
|
-
const isAvailable = (state, domainName) => {
|
|
51
|
-
return state.availability[domainName];
|
|
52
|
-
};
|
|
53
|
-
exports.isAvailable = isAvailable;
|
|
54
|
-
const getDomainAvailabilities = (state) => {
|
|
55
|
-
return state.availability;
|
|
56
|
-
};
|
|
57
|
-
exports.getDomainAvailabilities = getDomainAvailabilities;
|
|
58
|
-
//# sourceMappingURL=selectors.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"selectors.js","sourceRoot":"","sources":["../../../src/domain-suggestions/selectors.ts"],"names":[],"mappings":";;;AAAA,0CAAyC;AACzC,2CAAoD;AACpD,mCAAqF;AAW9E,MAAM,aAAa,GAAG,CAAE,KAAY,EAAqB,EAAE;IACjE,iDAAiD;IACjD,OAAO;QACN,GAAG,KAAK,CAAC,UAAU;aACjB,MAAM,CAAE,CAAE,EAAE,IAAI,EAAE,EAAG,EAAE,CAAC,IAAI,KAAK,IAAI,CAAE;aACvC,IAAI,CAAE,CAAE,CAAC,EAAE,CAAC,EAAG,EAAE,CAAC,CAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAE,CAAE;QACxC,GAAG,KAAK,CAAC,UAAU;aACjB,MAAM,CAAE,CAAE,EAAE,IAAI,EAAE,EAAG,EAAE,CAAC,IAAI,KAAK,IAAI,CAAE;aACvC,IAAI,CAAE,CAAE,CAAC,EAAE,CAAC,EAAG,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,aAAa,CAAE,CAAC,CAAC,KAAK,CAAE,CAAE;KAC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