@automattic/data-stores 3.2.0 → 3.2.1
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 +4 -0
- package/dist/cjs/agents-manager/actions.js +116 -0
- package/dist/cjs/agents-manager/actions.js.map +1 -0
- package/dist/cjs/agents-manager/constants.js +5 -0
- package/dist/cjs/agents-manager/constants.js.map +1 -0
- package/dist/cjs/agents-manager/index.js +37 -0
- package/dist/cjs/agents-manager/index.js.map +1 -0
- package/dist/cjs/agents-manager/persist-state.js +58 -0
- package/dist/cjs/agents-manager/persist-state.js.map +1 -0
- package/dist/cjs/agents-manager/reducer.js +87 -0
- package/dist/cjs/agents-manager/reducer.js.map +1 -0
- package/dist/cjs/agents-manager/resolvers.js +60 -0
- package/dist/cjs/agents-manager/resolvers.js.map +1 -0
- package/dist/cjs/agents-manager/selectors.js +44 -0
- package/dist/cjs/agents-manager/selectors.js.map +1 -0
- package/dist/cjs/agents-manager/types.js +3 -0
- package/dist/cjs/agents-manager/types.js.map +1 -0
- 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 +67 -63
- package/dist/cjs/help-center/actions.js.map +1 -1
- package/dist/cjs/help-center/constants.js +2 -1
- package/dist/cjs/help-center/constants.js.map +1 -1
- package/dist/cjs/help-center/index.js +14 -27
- package/dist/cjs/help-center/index.js.map +1 -1
- package/dist/cjs/help-center/reducer.js +17 -2
- package/dist/cjs/help-center/reducer.js.map +1 -1
- package/dist/cjs/help-center/resolvers.js +45 -25
- package/dist/cjs/help-center/resolvers.js.map +1 -1
- package/dist/cjs/help-center/selectors.js +7 -1
- package/dist/cjs/help-center/selectors.js.map +1 -1
- package/dist/cjs/help-center/utils.js +136 -0
- package/dist/cjs/help-center/utils.js.map +1 -0
- package/dist/cjs/index.js +8 -3
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/mutations/use-domains-bulk-actions-mutation.js +3 -3
- package/dist/cjs/mutations/use-domains-bulk-actions-mutation.js.map +1 -1
- package/dist/cjs/newsletter-categories/index.js +2 -2
- package/dist/cjs/newsletter-categories/index.js.map +1 -1
- package/dist/cjs/onboard/actions.js +6 -1
- package/dist/cjs/onboard/actions.js.map +1 -1
- package/dist/cjs/onboard/reducer.js +12 -1
- package/dist/cjs/onboard/reducer.js.map +1 -1
- package/dist/cjs/onboard/selectors.js +3 -1
- package/dist/cjs/onboard/selectors.js.map +1 -1
- package/dist/cjs/plans/constants.js +3 -1
- package/dist/cjs/plans/constants.js.map +1 -1
- package/dist/cjs/plans/hooks/use-pricing-meta-for-grid-plans.js +35 -18
- package/dist/cjs/plans/hooks/use-pricing-meta-for-grid-plans.js.map +1 -1
- package/dist/cjs/plans/index.js +2 -1
- package/dist/cjs/plans/index.js.map +1 -1
- package/dist/cjs/plans/queries/use-plans.js +2 -2
- package/dist/cjs/plans/queries/use-plans.js.map +1 -1
- package/dist/cjs/plans/queries/use-site-plans.js +2 -2
- package/dist/cjs/plans/queries/use-site-plans.js.map +1 -1
- package/dist/cjs/plans/resolvers.js +0 -1
- package/dist/cjs/plans/resolvers.js.map +1 -1
- package/dist/cjs/plans/selectors.js.map +1 -1
- package/dist/cjs/products-list/queries/use-products.js +2 -2
- package/dist/cjs/products-list/queries/use-products.js.map +1 -1
- package/dist/cjs/products-list/resolvers.js +2 -2
- package/dist/cjs/products-list/resolvers.js.map +1 -1
- package/dist/cjs/purchases/lib/assembler.js +9 -4
- package/dist/cjs/purchases/lib/assembler.js.map +1 -1
- package/dist/cjs/purchases/queries/use-get-jetpack-transferred-license-purchases.js +2 -2
- package/dist/cjs/purchases/queries/use-get-jetpack-transferred-license-purchases.js.map +1 -1
- package/dist/cjs/purchases/queries/use-site-purchases.js +3 -3
- package/dist/cjs/purchases/queries/use-site-purchases.js.map +1 -1
- package/dist/cjs/queries/use-all-domains-query.js +2 -2
- package/dist/cjs/queries/use-all-domains-query.js.map +1 -1
- package/dist/cjs/queries/use-bulk-domain-update-status-query.js +3 -57
- package/dist/cjs/queries/use-bulk-domain-update-status-query.js.map +1 -1
- package/dist/cjs/queries/use-happiness-engineers-query.js +2 -2
- package/dist/cjs/queries/use-happiness-engineers-query.js.map +1 -1
- package/dist/cjs/queries/use-launchpad.js +5 -5
- package/dist/cjs/queries/use-launchpad.js.map +1 -1
- package/dist/cjs/queries/use-site-domains-query.js +2 -2
- package/dist/cjs/queries/use-site-domains-query.js.map +1 -1
- package/dist/cjs/queries/use-site-intent.js +2 -2
- package/dist/cjs/queries/use-site-intent.js.map +1 -1
- package/dist/cjs/queries/use-site-query.js +2 -2
- package/dist/cjs/queries/use-site-query.js.map +1 -1
- package/dist/cjs/reader/contexts/index.js +1 -4
- package/dist/cjs/reader/contexts/index.js.map +1 -1
- package/dist/cjs/reader/helpers/index.js +4 -3
- package/dist/cjs/reader/helpers/index.js.map +1 -1
- package/dist/cjs/reader/helpers/optimistic-update.js +2 -1
- package/dist/cjs/reader/helpers/optimistic-update.js.map +1 -1
- package/dist/cjs/reader/index.js +2 -8
- package/dist/cjs/reader/index.js.map +1 -1
- package/dist/cjs/reader/mutations/use-pending-site-confirm-mutation.js +2 -2
- package/dist/cjs/reader/mutations/use-pending-site-confirm-mutation.js.map +1 -1
- package/dist/cjs/reader/mutations/use-site-delivery-frequency-mutation.js +26 -20
- package/dist/cjs/reader/mutations/use-site-delivery-frequency-mutation.js.map +1 -1
- package/dist/cjs/reader/mutations/use-site-email-me-new-comments-mutation.js +4 -3
- package/dist/cjs/reader/mutations/use-site-email-me-new-comments-mutation.js.map +1 -1
- package/dist/cjs/reader/mutations/use-site-email-me-new-posts-mutation.js +4 -3
- package/dist/cjs/reader/mutations/use-site-email-me-new-posts-mutation.js.map +1 -1
- package/dist/cjs/reader/mutations/use-site-notify-me-of-new-posts-mutation.js +4 -3
- package/dist/cjs/reader/mutations/use-site-notify-me-of-new-posts-mutation.js.map +1 -1
- package/dist/cjs/reader/mutations/use-site-subscribe-mutation.js +10 -4
- package/dist/cjs/reader/mutations/use-site-subscribe-mutation.js.map +1 -1
- package/dist/cjs/reader/mutations/use-site-unsubscribe-mutation.js +11 -4
- package/dist/cjs/reader/mutations/use-site-unsubscribe-mutation.js.map +1 -1
- package/dist/cjs/reader/queries/index.js +2 -8
- package/dist/cjs/reader/queries/index.js.map +1 -1
- package/dist/cjs/reader/queries/use-site-subscriptions-query.js +27 -26
- package/dist/cjs/reader/queries/use-site-subscriptions-query.js.map +1 -1
- package/dist/cjs/site/queries/use-site-features.js +2 -2
- package/dist/cjs/site/queries/use-site-features.js.map +1 -1
- package/dist/cjs/site/queries/use-site-media-storage.js +2 -2
- package/dist/cjs/site/queries/use-site-media-storage.js.map +1 -1
- package/dist/cjs/site/queries/use-site-user-query.js +2 -2
- package/dist/cjs/site/queries/use-site-user-query.js.map +1 -1
- package/dist/cjs/site/queries/use-site.js +2 -2
- package/dist/cjs/site/queries/use-site.js.map +1 -1
- package/dist/cjs/site/resolvers.js +5 -5
- package/dist/cjs/site/resolvers.js.map +1 -1
- package/dist/cjs/site/selectors.js +5 -3
- package/dist/cjs/site/selectors.js.map +1 -1
- package/dist/cjs/site/types.js.map +1 -1
- package/dist/cjs/site-reset/use-site-reset-content-summary-query.js +2 -2
- package/dist/cjs/site-reset/use-site-reset-content-summary-query.js.map +1 -1
- package/dist/cjs/site-reset/use-site-reset-mutation.js +2 -2
- package/dist/cjs/site-reset/use-site-reset-mutation.js.map +1 -1
- package/dist/cjs/site-reset/use-site-reset-status-query.js +2 -2
- package/dist/cjs/site-reset/use-site-reset-status-query.js.map +1 -1
- package/dist/cjs/starter-designs-queries/use-starter-design-by-slug.js +2 -2
- package/dist/cjs/starter-designs-queries/use-starter-design-by-slug.js.map +1 -1
- package/dist/cjs/starter-designs-queries/use-starter-designs-query.js +2 -2
- package/dist/cjs/starter-designs-queries/use-starter-designs-query.js.map +1 -1
- package/dist/cjs/subscriber/actions.js +5 -5
- package/dist/cjs/subscriber/actions.js.map +1 -1
- package/dist/cjs/templates/use-template.js +2 -2
- package/dist/cjs/templates/use-template.js.map +1 -1
- package/dist/cjs/users/use-send-invites.js +2 -2
- package/dist/cjs/users/use-send-invites.js.map +1 -1
- package/dist/cjs/utils.js +26 -0
- package/dist/cjs/utils.js.map +1 -0
- package/dist/cjs/wpcom-request-controls/index.js +3 -2
- package/dist/cjs/wpcom-request-controls/index.js.map +1 -1
- package/dist/cjs/wpcom-request.js +24 -0
- package/dist/cjs/wpcom-request.js.map +1 -0
- package/dist/esm/agents-manager/actions.js +104 -0
- package/dist/esm/agents-manager/actions.js.map +1 -0
- package/dist/esm/agents-manager/constants.js +2 -0
- package/dist/esm/agents-manager/constants.js.map +1 -0
- package/dist/esm/agents-manager/index.js +31 -0
- package/dist/esm/agents-manager/index.js.map +1 -0
- package/dist/esm/agents-manager/persist-state.js +54 -0
- package/dist/esm/agents-manager/persist-state.js.map +1 -0
- package/dist/esm/agents-manager/reducer.js +82 -0
- package/dist/esm/agents-manager/reducer.js.map +1 -0
- package/dist/esm/agents-manager/resolvers.js +57 -0
- package/dist/esm/agents-manager/resolvers.js.map +1 -0
- package/dist/esm/agents-manager/selectors.js +31 -0
- package/dist/esm/agents-manager/selectors.js.map +1 -0
- package/dist/esm/agents-manager/types.js +2 -0
- package/dist/esm/agents-manager/types.js.map +1 -0
- 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 +63 -61
- package/dist/esm/help-center/actions.js.map +1 -1
- package/dist/esm/help-center/constants.js +1 -0
- package/dist/esm/help-center/constants.js.map +1 -1
- package/dist/esm/help-center/index.js +11 -23
- package/dist/esm/help-center/index.js.map +1 -1
- package/dist/esm/help-center/reducer.js +17 -2
- package/dist/esm/help-center/reducer.js.map +1 -1
- package/dist/esm/help-center/resolvers.js +43 -25
- package/dist/esm/help-center/resolvers.js.map +1 -1
- package/dist/esm/help-center/selectors.js +3 -0
- package/dist/esm/help-center/selectors.js.map +1 -1
- package/dist/esm/help-center/utils.js +127 -0
- package/dist/esm/help-center/utils.js.map +1 -0
- package/dist/esm/index.js +4 -2
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/mutations/use-domains-bulk-actions-mutation.js +1 -1
- package/dist/esm/mutations/use-domains-bulk-actions-mutation.js.map +1 -1
- package/dist/esm/newsletter-categories/index.js +1 -1
- package/dist/esm/newsletter-categories/index.js.map +1 -1
- package/dist/esm/onboard/actions.js +4 -0
- package/dist/esm/onboard/actions.js.map +1 -1
- package/dist/esm/onboard/reducer.js +10 -0
- package/dist/esm/onboard/reducer.js.map +1 -1
- package/dist/esm/onboard/selectors.js +1 -0
- package/dist/esm/onboard/selectors.js.map +1 -1
- package/dist/esm/plans/constants.js +2 -0
- package/dist/esm/plans/constants.js.map +1 -1
- package/dist/esm/plans/hooks/use-pricing-meta-for-grid-plans.js +35 -18
- package/dist/esm/plans/hooks/use-pricing-meta-for-grid-plans.js.map +1 -1
- package/dist/esm/plans/index.js +1 -1
- package/dist/esm/plans/index.js.map +1 -1
- package/dist/esm/plans/queries/use-plans.js +1 -1
- package/dist/esm/plans/queries/use-site-plans.js +1 -1
- package/dist/esm/plans/resolvers.js +0 -1
- package/dist/esm/plans/resolvers.js.map +1 -1
- package/dist/esm/plans/selectors.js.map +1 -1
- package/dist/esm/products-list/queries/use-products.js +1 -1
- package/dist/esm/products-list/queries/use-products.js.map +1 -1
- package/dist/esm/products-list/resolvers.js +1 -1
- package/dist/esm/products-list/resolvers.js.map +1 -1
- package/dist/esm/purchases/lib/assembler.js +9 -4
- package/dist/esm/purchases/lib/assembler.js.map +1 -1
- package/dist/esm/purchases/queries/use-get-jetpack-transferred-license-purchases.js +1 -1
- package/dist/esm/purchases/queries/use-site-purchases.js +2 -2
- package/dist/esm/queries/use-all-domains-query.js +1 -1
- package/dist/esm/queries/use-all-domains-query.js.map +1 -1
- package/dist/esm/queries/use-bulk-domain-update-status-query.js +3 -56
- package/dist/esm/queries/use-bulk-domain-update-status-query.js.map +1 -1
- package/dist/esm/queries/use-happiness-engineers-query.js +1 -1
- package/dist/esm/queries/use-happiness-engineers-query.js.map +1 -1
- package/dist/esm/queries/use-launchpad.js +1 -1
- package/dist/esm/queries/use-launchpad.js.map +1 -1
- package/dist/esm/queries/use-site-domains-query.js +1 -1
- package/dist/esm/queries/use-site-domains-query.js.map +1 -1
- package/dist/esm/queries/use-site-intent.js +1 -1
- package/dist/esm/queries/use-site-intent.js.map +1 -1
- package/dist/esm/queries/use-site-query.js +1 -1
- package/dist/esm/queries/use-site-query.js.map +1 -1
- package/dist/esm/reader/contexts/index.js +0 -1
- package/dist/esm/reader/contexts/index.js.map +1 -1
- package/dist/esm/reader/helpers/index.js +3 -2
- package/dist/esm/reader/helpers/index.js.map +1 -1
- package/dist/esm/reader/helpers/optimistic-update.js +2 -1
- package/dist/esm/reader/helpers/optimistic-update.js.map +1 -1
- package/dist/esm/reader/index.js +2 -3
- package/dist/esm/reader/index.js.map +1 -1
- package/dist/esm/reader/mutations/use-pending-site-confirm-mutation.js +2 -2
- package/dist/esm/reader/mutations/use-pending-site-confirm-mutation.js.map +1 -1
- package/dist/esm/reader/mutations/use-site-delivery-frequency-mutation.js +27 -21
- package/dist/esm/reader/mutations/use-site-delivery-frequency-mutation.js.map +1 -1
- package/dist/esm/reader/mutations/use-site-email-me-new-comments-mutation.js +5 -4
- package/dist/esm/reader/mutations/use-site-email-me-new-comments-mutation.js.map +1 -1
- package/dist/esm/reader/mutations/use-site-email-me-new-posts-mutation.js +5 -4
- package/dist/esm/reader/mutations/use-site-email-me-new-posts-mutation.js.map +1 -1
- package/dist/esm/reader/mutations/use-site-notify-me-of-new-posts-mutation.js +5 -4
- package/dist/esm/reader/mutations/use-site-notify-me-of-new-posts-mutation.js.map +1 -1
- package/dist/esm/reader/mutations/use-site-subscribe-mutation.js +10 -4
- package/dist/esm/reader/mutations/use-site-subscribe-mutation.js.map +1 -1
- package/dist/esm/reader/mutations/use-site-unsubscribe-mutation.js +11 -4
- package/dist/esm/reader/mutations/use-site-unsubscribe-mutation.js.map +1 -1
- package/dist/esm/reader/queries/index.js +1 -4
- package/dist/esm/reader/queries/index.js.map +1 -1
- package/dist/esm/reader/queries/use-site-subscriptions-query.js +28 -27
- package/dist/esm/reader/queries/use-site-subscriptions-query.js.map +1 -1
- package/dist/esm/site/queries/use-site-features.js +1 -1
- package/dist/esm/site/queries/use-site-media-storage.js +1 -1
- package/dist/esm/site/queries/use-site-user-query.js +1 -1
- package/dist/esm/site/queries/use-site-user-query.js.map +1 -1
- package/dist/esm/site/queries/use-site.js +1 -1
- package/dist/esm/site/resolvers.js +1 -1
- package/dist/esm/site/resolvers.js.map +1 -1
- package/dist/esm/site/selectors.js +5 -3
- package/dist/esm/site/selectors.js.map +1 -1
- package/dist/esm/site/types.js.map +1 -1
- package/dist/esm/site-reset/use-site-reset-content-summary-query.js +1 -1
- package/dist/esm/site-reset/use-site-reset-content-summary-query.js.map +1 -1
- package/dist/esm/site-reset/use-site-reset-mutation.js +1 -1
- package/dist/esm/site-reset/use-site-reset-mutation.js.map +1 -1
- package/dist/esm/site-reset/use-site-reset-status-query.js +1 -1
- package/dist/esm/site-reset/use-site-reset-status-query.js.map +1 -1
- package/dist/esm/starter-designs-queries/use-starter-design-by-slug.js +1 -1
- package/dist/esm/starter-designs-queries/use-starter-design-by-slug.js.map +1 -1
- package/dist/esm/starter-designs-queries/use-starter-designs-query.js +1 -1
- package/dist/esm/starter-designs-queries/use-starter-designs-query.js.map +1 -1
- package/dist/esm/subscriber/actions.js +1 -1
- package/dist/esm/subscriber/actions.js.map +1 -1
- package/dist/esm/templates/use-template.js +1 -1
- package/dist/esm/templates/use-template.js.map +1 -1
- package/dist/esm/users/use-send-invites.js +1 -1
- package/dist/esm/users/use-send-invites.js.map +1 -1
- package/dist/esm/utils.js +21 -0
- package/dist/esm/utils.js.map +1 -0
- package/dist/esm/wpcom-request-controls/index.js +2 -1
- package/dist/esm/wpcom-request-controls/index.js.map +1 -1
- package/dist/esm/wpcom-request.js +18 -0
- package/dist/esm/wpcom-request.js.map +1 -0
- package/dist/tsconfig-cjs.tsbuildinfo +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/types/add-ons/types.d.ts +1 -0
- package/dist/types/add-ons/types.d.ts.map +1 -1
- package/dist/types/agents-manager/actions.d.ts +77 -0
- package/dist/types/agents-manager/actions.d.ts.map +1 -0
- package/dist/types/agents-manager/constants.d.ts +2 -0
- package/dist/types/agents-manager/constants.d.ts.map +1 -0
- package/dist/types/agents-manager/index.d.ts +6 -0
- package/dist/types/agents-manager/index.d.ts.map +1 -0
- package/dist/types/agents-manager/persist-state.d.ts +6 -0
- package/dist/types/agents-manager/persist-state.d.ts.map +1 -0
- package/dist/types/agents-manager/reducer.d.ts +29 -0
- package/dist/types/agents-manager/reducer.d.ts.map +1 -0
- package/dist/types/agents-manager/resolvers.d.ts +54 -0
- package/dist/types/agents-manager/resolvers.d.ts.map +1 -0
- package/dist/types/agents-manager/selectors.d.ts +22 -0
- package/dist/types/agents-manager/selectors.d.ts.map +1 -0
- package/dist/types/agents-manager/types.d.ts +20 -0
- package/dist/types/agents-manager/types.d.ts.map +1 -0
- package/dist/types/contextual-help/admin-sections.d.ts +330 -6
- package/dist/types/contextual-help/admin-sections.d.ts.map +1 -1
- package/dist/types/contextual-help/contextual-help.d.ts +410 -30
- package/dist/types/contextual-help/contextual-help.d.ts.map +1 -1
- package/dist/types/help-center/actions.d.ts +235 -30
- package/dist/types/help-center/actions.d.ts.map +1 -1
- package/dist/types/help-center/constants.d.ts +1 -0
- package/dist/types/help-center/constants.d.ts.map +1 -1
- package/dist/types/help-center/index.d.ts +1 -2
- package/dist/types/help-center/index.d.ts.map +1 -1
- package/dist/types/help-center/reducer.d.ts +13 -2
- package/dist/types/help-center/reducer.d.ts.map +1 -1
- package/dist/types/help-center/resolvers.d.ts +4 -31
- package/dist/types/help-center/resolvers.d.ts.map +1 -1
- package/dist/types/help-center/selectors.d.ts +11 -1
- package/dist/types/help-center/selectors.d.ts.map +1 -1
- package/dist/types/help-center/types.d.ts +20 -12
- package/dist/types/help-center/types.d.ts.map +1 -1
- package/dist/types/help-center/utils.d.ts +13 -0
- package/dist/types/help-center/utils.d.ts.map +1 -0
- package/dist/types/index.d.ts +18 -298
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/onboard/actions.d.ts +19 -3
- package/dist/types/onboard/actions.d.ts.map +1 -1
- package/dist/types/onboard/reducer.d.ts +4 -1
- package/dist/types/onboard/reducer.d.ts.map +1 -1
- package/dist/types/onboard/selectors.d.ts +8 -6
- package/dist/types/onboard/selectors.d.ts.map +1 -1
- package/dist/types/plans/constants.d.ts +3 -2
- package/dist/types/plans/constants.d.ts.map +1 -1
- package/dist/types/plans/hooks/use-pricing-meta-for-grid-plans.d.ts +6 -1
- package/dist/types/plans/hooks/use-pricing-meta-for-grid-plans.d.ts.map +1 -1
- package/dist/types/plans/index.d.ts +1 -1
- package/dist/types/plans/index.d.ts.map +1 -1
- package/dist/types/plans/resolvers.d.ts.map +1 -1
- package/dist/types/plans/types.d.ts +6 -0
- package/dist/types/plans/types.d.ts.map +1 -1
- package/dist/types/products-list/index.d.ts +1 -1
- package/dist/types/products-list/index.d.ts.map +1 -1
- package/dist/types/products-list/queries/use-products.d.ts.map +1 -1
- package/dist/types/purchases/lib/assembler.d.ts.map +1 -1
- package/dist/types/purchases/types.d.ts +37 -0
- package/dist/types/purchases/types.d.ts.map +1 -1
- package/dist/types/queries/use-all-domains-query.d.ts +2 -2
- package/dist/types/queries/use-all-domains-query.d.ts.map +1 -1
- package/dist/types/queries/use-bulk-domain-update-status-query.d.ts +5 -48
- package/dist/types/queries/use-bulk-domain-update-status-query.d.ts.map +1 -1
- package/dist/types/queries/use-site-intent.d.ts.map +1 -1
- package/dist/types/reader/contexts/index.d.ts +0 -1
- package/dist/types/reader/contexts/index.d.ts.map +1 -1
- package/dist/types/reader/helpers/index.d.ts.map +1 -1
- package/dist/types/reader/helpers/optimistic-update.d.ts.map +1 -1
- package/dist/types/reader/index.d.ts +13 -299
- package/dist/types/reader/index.d.ts.map +1 -1
- package/dist/types/reader/mutations/use-site-delivery-frequency-mutation.d.ts +3 -2
- package/dist/types/reader/mutations/use-site-delivery-frequency-mutation.d.ts.map +1 -1
- package/dist/types/reader/mutations/use-site-email-me-new-comments-mutation.d.ts +3 -2
- package/dist/types/reader/mutations/use-site-email-me-new-comments-mutation.d.ts.map +1 -1
- package/dist/types/reader/mutations/use-site-email-me-new-posts-mutation.d.ts +3 -2
- package/dist/types/reader/mutations/use-site-email-me-new-posts-mutation.d.ts.map +1 -1
- package/dist/types/reader/mutations/use-site-notify-me-of-new-posts-mutation.d.ts +3 -2
- package/dist/types/reader/mutations/use-site-notify-me-of-new-posts-mutation.d.ts.map +1 -1
- package/dist/types/reader/mutations/use-site-subscribe-mutation.d.ts +3 -2
- package/dist/types/reader/mutations/use-site-subscribe-mutation.d.ts.map +1 -1
- package/dist/types/reader/mutations/use-site-unsubscribe-mutation.d.ts +3 -2
- package/dist/types/reader/mutations/use-site-unsubscribe-mutation.d.ts.map +1 -1
- package/dist/types/reader/queries/index.d.ts +1 -5
- package/dist/types/reader/queries/index.d.ts.map +1 -1
- package/dist/types/reader/queries/use-site-subscriptions-query.d.ts +6 -225
- package/dist/types/reader/queries/use-site-subscriptions-query.d.ts.map +1 -1
- package/dist/types/reader/types/index.d.ts +32 -44
- package/dist/types/reader/types/index.d.ts.map +1 -1
- package/dist/types/shared-types.d.ts +11 -0
- package/dist/types/shared-types.d.ts.map +1 -1
- package/dist/types/site/actions.d.ts +1 -1
- package/dist/types/site/actions.d.ts.map +1 -1
- package/dist/types/site/queries/use-site-user-query.d.ts.map +1 -1
- package/dist/types/site/selectors.d.ts.map +1 -1
- package/dist/types/site/types.d.ts +4 -1
- package/dist/types/site/types.d.ts.map +1 -1
- package/dist/types/starter-designs-queries/types.d.ts +1 -1
- package/dist/types/starter-designs-queries/types.d.ts.map +1 -1
- package/dist/types/starter-designs-queries/use-starter-design-by-slug.d.ts +1 -1
- package/dist/types/starter-designs-queries/use-starter-design-by-slug.d.ts.map +1 -1
- package/dist/types/starter-designs-queries/use-starter-designs-query.d.ts +1 -1
- package/dist/types/starter-designs-queries/use-starter-designs-query.d.ts.map +1 -1
- package/dist/types/subscriber/index.d.ts +1 -1
- package/dist/types/subscriber/index.d.ts.map +1 -1
- package/dist/types/utils.d.ts +3 -0
- package/dist/types/utils.d.ts.map +1 -0
- package/dist/types/wpcom-plans-ui/actions.d.ts +1 -1
- package/dist/types/wpcom-plans-ui/index.d.ts +1 -1
- package/dist/types/wpcom-plans-ui/index.d.ts.map +1 -1
- package/dist/types/wpcom-request-controls/index.d.ts +1 -1
- package/dist/types/wpcom-request-controls/index.d.ts.map +1 -1
- package/dist/types/wpcom-request.d.ts +7 -0
- package/dist/types/wpcom-request.d.ts.map +1 -0
- package/package.json +23 -22
- package/src/add-ons/types.ts +1 -0
- package/src/agents-manager/actions.ts +151 -0
- package/src/agents-manager/constants.ts +1 -0
- package/src/agents-manager/index.ts +38 -0
- package/src/agents-manager/persist-state.ts +60 -0
- package/src/agents-manager/reducer.ts +106 -0
- package/src/agents-manager/resolvers.ts +87 -0
- package/src/agents-manager/selectors.ts +32 -0
- package/src/agents-manager/test/persist-state.test.ts +81 -0
- package/src/agents-manager/test/reducer.test.ts +69 -0
- package/src/agents-manager/types.ts +24 -0
- package/src/contextual-help/admin-sections.ts +1 -1
- package/src/help-center/actions.ts +101 -76
- package/src/help-center/constants.ts +1 -0
- package/src/help-center/index.ts +11 -32
- package/src/help-center/reducer.ts +29 -5
- package/src/help-center/resolvers.ts +46 -38
- package/src/help-center/selectors.ts +3 -0
- package/src/help-center/test/utils.ts +99 -0
- package/src/help-center/types.ts +22 -13
- package/src/help-center/utils.ts +156 -0
- package/src/index.ts +11 -1
- package/src/mutations/use-domains-bulk-actions-mutation.ts +1 -1
- package/src/newsletter-categories/index.ts +1 -1
- package/src/newsletter-categories/test/index.tsx +5 -2
- package/src/onboard/actions.ts +7 -2
- package/src/onboard/reducer.ts +12 -2
- package/src/onboard/selectors.ts +1 -0
- package/src/plans/constants.ts +2 -0
- package/src/plans/hooks/test/use-pricing-meta-for-grid-plans.ts +120 -0
- package/src/plans/hooks/use-pricing-meta-for-grid-plans.ts +48 -18
- package/src/plans/index.ts +1 -0
- package/src/plans/queries/use-plans.ts +1 -1
- package/src/plans/queries/use-site-plans.ts +1 -1
- package/src/plans/resolvers.ts +0 -1
- package/src/plans/selectors.ts +9 -9
- package/src/plans/types.ts +6 -0
- package/src/products-list/queries/use-products.ts +1 -1
- package/src/products-list/resolvers.ts +1 -1
- package/src/products-list/selectors.ts +1 -1
- package/src/products-list/test/selectors.ts +2 -2
- package/src/purchases/lib/assembler.ts +10 -4
- package/src/purchases/queries/use-get-jetpack-transferred-license-purchases.tsx +1 -1
- package/src/purchases/queries/use-site-purchases.ts +2 -2
- package/src/purchases/types.ts +43 -0
- package/src/queries/use-all-domains-query.ts +3 -3
- package/src/queries/use-bulk-domain-update-status-query.ts +14 -115
- package/src/queries/use-happiness-engineers-query.ts +1 -1
- package/src/queries/use-launchpad.ts +1 -1
- package/src/queries/use-site-domains-query.ts +1 -1
- package/src/queries/use-site-intent.ts +1 -1
- package/src/queries/use-site-query.ts +1 -1
- package/src/reader/contexts/index.ts +0 -4
- package/src/reader/helpers/index.ts +3 -2
- package/src/reader/helpers/optimistic-update.ts +2 -1
- package/src/reader/index.ts +2 -4
- package/src/reader/mutations/test/use-site-subscription-mutations.test.tsx +208 -0
- package/src/reader/mutations/use-pending-site-confirm-mutation.ts +2 -2
- package/src/reader/mutations/use-site-delivery-frequency-mutation.ts +32 -36
- package/src/reader/mutations/use-site-email-me-new-comments-mutation.ts +10 -10
- package/src/reader/mutations/use-site-email-me-new-posts-mutation.ts +10 -10
- package/src/reader/mutations/use-site-notify-me-of-new-posts-mutation.ts +10 -10
- package/src/reader/mutations/use-site-subscribe-mutation.ts +21 -10
- package/src/reader/mutations/use-site-unsubscribe-mutation.ts +20 -10
- package/src/reader/queries/index.ts +4 -6
- package/src/reader/queries/test/use-site-subscriptions-query.tsx +158 -52
- package/src/reader/queries/use-site-subscriptions-query.ts +53 -55
- package/src/reader/types/index.ts +34 -48
- package/src/shared-types.ts +13 -0
- package/src/site/actions.ts +1 -1
- package/src/site/queries/use-site-features.ts +1 -1
- package/src/site/queries/use-site-media-storage.ts +1 -1
- package/src/site/queries/use-site-user-query.ts +1 -1
- package/src/site/queries/use-site.ts +1 -1
- package/src/site/resolvers.ts +1 -1
- package/src/site/selectors.ts +18 -10
- package/src/site/test/selectors.ts +3 -3
- package/src/site/types.ts +4 -1
- package/src/site-reset/test/use-site-reset-mutation.tsx +3 -4
- package/src/site-reset/use-site-reset-content-summary-query.ts +1 -1
- package/src/site-reset/use-site-reset-mutation.ts +1 -1
- package/src/site-reset/use-site-reset-status-query.ts +1 -1
- package/src/starter-designs-queries/types.ts +1 -1
- package/src/starter-designs-queries/use-starter-design-by-slug.ts +2 -2
- package/src/starter-designs-queries/use-starter-designs-query.ts +2 -2
- package/src/subscriber/actions.ts +1 -1
- package/src/templates/use-template.ts +1 -1
- package/src/users/use-send-invites.ts +1 -1
- package/src/utils.ts +33 -0
- package/src/wpcom-request-controls/index.ts +2 -1
- package/src/wpcom-request.ts +26 -0
- package/dist/cjs/reader/contexts/unsubscribed-feeds-search.js +0 -26
- package/dist/cjs/reader/contexts/unsubscribed-feeds-search.js.map +0 -1
- package/dist/cjs/reader/queries/use-read-feed-query.js +0 -21
- package/dist/cjs/reader/queries/use-read-feed-query.js.map +0 -1
- package/dist/cjs/reader/queries/use-read-feed-search-query.js +0 -39
- package/dist/cjs/reader/queries/use-read-feed-search-query.js.map +0 -1
- package/dist/cjs/reader/queries/use-read-feed-site-query.js +0 -26
- package/dist/cjs/reader/queries/use-read-feed-site-query.js.map +0 -1
- package/dist/esm/reader/contexts/unsubscribed-feeds-search.js +0 -20
- package/dist/esm/reader/contexts/unsubscribed-feeds-search.js.map +0 -1
- package/dist/esm/reader/queries/use-read-feed-query.js +0 -18
- package/dist/esm/reader/queries/use-read-feed-query.js.map +0 -1
- package/dist/esm/reader/queries/use-read-feed-search-query.js +0 -35
- package/dist/esm/reader/queries/use-read-feed-search-query.js.map +0 -1
- package/dist/esm/reader/queries/use-read-feed-site-query.js +0 -23
- package/dist/esm/reader/queries/use-read-feed-site-query.js.map +0 -1
- package/dist/types/reader/contexts/unsubscribed-feeds-search.d.ts +0 -12
- package/dist/types/reader/contexts/unsubscribed-feeds-search.d.ts.map +0 -1
- package/dist/types/reader/queries/use-read-feed-query.d.ts +0 -28
- package/dist/types/reader/queries/use-read-feed-query.d.ts.map +0 -1
- package/dist/types/reader/queries/use-read-feed-search-query.d.ts +0 -34
- package/dist/types/reader/queries/use-read-feed-search-query.d.ts.map +0 -1
- package/dist/types/reader/queries/use-read-feed-site-query.d.ts +0 -15
- package/dist/types/reader/queries/use-read-feed-site-query.d.ts.map +0 -1
- package/src/reader/contexts/unsubscribed-feeds-search.tsx +0 -35
- package/src/reader/queries/test/use-read-feed-search-query.tsx +0 -55
- package/src/reader/queries/use-read-feed-query.ts +0 -45
- package/src/reader/queries/use-read-feed-search-query.ts +0 -72
- package/src/reader/queries/use-read-feed-site-query.ts +0 -35
|
@@ -1,130 +1,29 @@
|
|
|
1
|
+
import {
|
|
2
|
+
type BulkDomainUpdateStatusQueryFnData,
|
|
3
|
+
type BulkDomainUpdateStatusResult,
|
|
4
|
+
} from '@automattic/api-core';
|
|
5
|
+
import { bulkDomainUpdateStatusQuery } from '@automattic/api-queries';
|
|
1
6
|
import { type UseQueryOptions, useQuery } from '@tanstack/react-query';
|
|
2
|
-
import wpcomRequest from 'wpcom-proxy-request';
|
|
3
|
-
|
|
4
|
-
export interface BulkDomainUpdateStatus {
|
|
5
|
-
results: {
|
|
6
|
-
[ key: string ]: '' | 'success' | 'failed';
|
|
7
|
-
};
|
|
8
|
-
action: 'set_auto_renew' | 'update_contact_info';
|
|
9
|
-
created_at: number;
|
|
10
|
-
auto_renew?: boolean;
|
|
11
|
-
whois?: unknown;
|
|
12
|
-
transfer_lock?: boolean;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
export interface BulkDomainUpdateStatusQueryFnData {
|
|
16
|
-
[ key: string ]: BulkDomainUpdateStatus;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
export interface JobStatus {
|
|
20
|
-
id: string;
|
|
21
|
-
action: 'set_auto_renew' | 'update_contact_info';
|
|
22
|
-
created_at: number;
|
|
23
|
-
success: string[];
|
|
24
|
-
failed: string[];
|
|
25
|
-
pending: string[];
|
|
26
|
-
complete: boolean;
|
|
27
|
-
params: {
|
|
28
|
-
auto_renew?: boolean;
|
|
29
|
-
whois?: unknown;
|
|
30
|
-
transfer_lock?: boolean;
|
|
31
|
-
};
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
interface DomainUpdateRemoteStatus {
|
|
35
|
-
status: '' | 'success' | 'failed';
|
|
36
|
-
action: 'set_auto_renew' | 'update_contact_info';
|
|
37
|
-
created_at: number;
|
|
38
|
-
auto_renew?: boolean;
|
|
39
|
-
whois?: unknown;
|
|
40
|
-
transfer_lock?: boolean;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
interface DomainUpdateDerivedStatus {
|
|
44
|
-
status: '';
|
|
45
|
-
message: string;
|
|
46
|
-
created_at: number;
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
export type DomainUpdateStatus = DomainUpdateRemoteStatus | DomainUpdateDerivedStatus;
|
|
50
7
|
|
|
51
8
|
export const getBulkDomainUpdateStatusQueryKey = () => {
|
|
52
|
-
return
|
|
9
|
+
return bulkDomainUpdateStatusQuery().queryKey;
|
|
53
10
|
};
|
|
54
11
|
|
|
55
|
-
export
|
|
56
|
-
domainResults: Map< string, DomainUpdateStatus[] >;
|
|
57
|
-
completedJobs: JobStatus[];
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
export function useBulkDomainUpdateStatusQuery< TError = unknown >(
|
|
12
|
+
export function useBulkDomainUpdateStatusQuery(
|
|
61
13
|
pollingInterval: number,
|
|
62
14
|
options: Omit<
|
|
63
|
-
UseQueryOptions<
|
|
15
|
+
UseQueryOptions<
|
|
16
|
+
BulkDomainUpdateStatusQueryFnData,
|
|
17
|
+
Error,
|
|
18
|
+
BulkDomainUpdateStatusResult,
|
|
19
|
+
string[]
|
|
20
|
+
>,
|
|
64
21
|
'queryKey'
|
|
65
22
|
> = {}
|
|
66
23
|
) {
|
|
67
24
|
return useQuery( {
|
|
68
|
-
|
|
69
|
-
wpcomRequest< BulkDomainUpdateStatusQueryFnData >( {
|
|
70
|
-
path: '/domains/bulk-actions',
|
|
71
|
-
apiNamespace: 'wpcom/v2',
|
|
72
|
-
} ),
|
|
73
|
-
select: ( data ): BulkDomainUpdateStatusResult => {
|
|
74
|
-
// get top-level info about recent jobs
|
|
75
|
-
const allJobs: JobStatus[] = Object.keys( data ).map( ( jobId ) => {
|
|
76
|
-
const { action, created_at, results, ...rest } = data[ jobId ];
|
|
77
|
-
const success: string[] = [];
|
|
78
|
-
const failed: string[] = [];
|
|
79
|
-
const pending: string[] = [];
|
|
80
|
-
|
|
81
|
-
Object.entries( results ).forEach( ( entry ) => {
|
|
82
|
-
if ( entry[ 1 ] === 'success' ) {
|
|
83
|
-
success.push( entry[ 0 ] );
|
|
84
|
-
} else if ( entry[ 1 ] === 'failed' ) {
|
|
85
|
-
failed.push( entry[ 0 ] );
|
|
86
|
-
} else {
|
|
87
|
-
pending.push( entry[ 0 ] );
|
|
88
|
-
}
|
|
89
|
-
} );
|
|
90
|
-
|
|
91
|
-
return {
|
|
92
|
-
id: jobId,
|
|
93
|
-
action: action,
|
|
94
|
-
created_at: created_at,
|
|
95
|
-
success,
|
|
96
|
-
failed,
|
|
97
|
-
pending,
|
|
98
|
-
complete: pending.length === 0,
|
|
99
|
-
params: rest,
|
|
100
|
-
};
|
|
101
|
-
} );
|
|
102
|
-
|
|
103
|
-
// get domain-level updates that can be shown inline in the table rows
|
|
104
|
-
const domainResults = new Map< string, DomainUpdateStatus[] >();
|
|
105
|
-
|
|
106
|
-
Object.keys( data ).forEach( ( jobId ) => {
|
|
107
|
-
// only create domain-level results for jobs that
|
|
108
|
-
// are still running
|
|
109
|
-
if ( ! allJobs.find( ( job ) => job.id === jobId )?.complete ) {
|
|
110
|
-
const entry = data[ jobId ] as BulkDomainUpdateStatus;
|
|
111
|
-
const { results, ...rest } = entry;
|
|
112
|
-
Object.keys( results ).forEach( ( domain ) => {
|
|
113
|
-
if ( ! domainResults.has( domain ) ) {
|
|
114
|
-
domainResults.set( domain, [] );
|
|
115
|
-
}
|
|
116
|
-
const status = results[ domain ];
|
|
117
|
-
domainResults.get( domain )?.push( { ...rest, status } );
|
|
118
|
-
} );
|
|
119
|
-
}
|
|
120
|
-
} );
|
|
121
|
-
|
|
122
|
-
const completedJobs = allJobs.filter( ( job ) => job.complete );
|
|
123
|
-
|
|
124
|
-
return { domainResults, completedJobs };
|
|
125
|
-
},
|
|
25
|
+
...bulkDomainUpdateStatusQuery(),
|
|
126
26
|
refetchInterval: pollingInterval,
|
|
127
27
|
...options,
|
|
128
|
-
queryKey: getBulkDomainUpdateStatusQueryKey(),
|
|
129
28
|
} );
|
|
130
29
|
}
|
|
@@ -3,7 +3,7 @@ import * as oauthToken from '@automattic/oauth-token';
|
|
|
3
3
|
import { useMutation, useQuery, useQueryClient } from '@tanstack/react-query';
|
|
4
4
|
import apiFetch from '@wordpress/api-fetch';
|
|
5
5
|
import { addQueryArgs } from '@wordpress/url';
|
|
6
|
-
import wpcomRequest, { canAccessWpcomApis } from 'wpcom-
|
|
6
|
+
import wpcomRequest, { canAccessWpcomApis } from '../wpcom-request';
|
|
7
7
|
|
|
8
8
|
interface APIFetchOptions {
|
|
9
9
|
global: boolean;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { useQuery } from '@tanstack/react-query';
|
|
2
|
-
import wpcomRequest from 'wpcom-proxy-request';
|
|
3
2
|
import { SiteIntent } from '../onboard';
|
|
3
|
+
import wpcomRequest from '../wpcom-request';
|
|
4
4
|
|
|
5
5
|
export function useSiteIntent( siteId: string | number | undefined ) {
|
|
6
6
|
return useQuery< {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { SiteDetails } from '@automattic/data-stores/src/site';
|
|
2
2
|
import { UseQueryOptions, useQuery } from '@tanstack/react-query';
|
|
3
|
-
import wpcomRequest from 'wpcom-
|
|
3
|
+
import wpcomRequest from '../wpcom-request';
|
|
4
4
|
|
|
5
5
|
export function useSiteQuery< TError = unknown, TData = SiteDetails >(
|
|
6
6
|
sourceSiteSlug: string | number | null | undefined,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import apiFetch, { APIFetchOptions } from '@wordpress/api-fetch';
|
|
2
|
-
import wpcomRequest from 'wpcom-
|
|
2
|
+
import wpcomRequest from '../../wpcom-request';
|
|
3
3
|
import isValidId from './validators';
|
|
4
4
|
|
|
5
5
|
type callApiParams = {
|
|
@@ -47,7 +47,7 @@ async function callApi< ReturnType >( {
|
|
|
47
47
|
? `https://public-api.wordpress.com/wpcom/v2${ path }`
|
|
48
48
|
: `https://public-api.wordpress.com/rest/v${ apiVersion }${ path }`;
|
|
49
49
|
|
|
50
|
-
|
|
50
|
+
const res = await apiFetch( {
|
|
51
51
|
global: true,
|
|
52
52
|
path: apiPath,
|
|
53
53
|
apiVersion,
|
|
@@ -59,6 +59,7 @@ async function callApi< ReturnType >( {
|
|
|
59
59
|
'Content-Type': 'application/json',
|
|
60
60
|
},
|
|
61
61
|
} as APIFetchOptions );
|
|
62
|
+
return res as ReturnType;
|
|
62
63
|
}
|
|
63
64
|
|
|
64
65
|
interface PagedResult< T > {
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { getSiteSubscriptionsQueryKey } from '@automattic/api-queries';
|
|
1
2
|
import { QueryClient } from '@tanstack/react-query';
|
|
2
3
|
import { SiteSubscriptionDetails } from '../types';
|
|
3
4
|
import { buildQueryKey } from './index';
|
|
@@ -66,7 +67,7 @@ const invalidateSiteSubscriptionDetails = (
|
|
|
66
67
|
queryClient: QueryClient,
|
|
67
68
|
{ blogId, subscriptionId, isLoggedIn, id }: SiteSubScriptionDetailsParameters
|
|
68
69
|
) => {
|
|
69
|
-
queryClient.invalidateQueries( { queryKey:
|
|
70
|
+
queryClient.invalidateQueries( { queryKey: getSiteSubscriptionsQueryKey() } );
|
|
70
71
|
queryClient.invalidateQueries( {
|
|
71
72
|
queryKey: buildQueryKey( [ 'read', 'site-subscription-details', blogId ], isLoggedIn, id ),
|
|
72
73
|
} );
|
package/src/reader/index.ts
CHANGED
|
@@ -17,6 +17,7 @@ import {
|
|
|
17
17
|
} from './mutations';
|
|
18
18
|
import {
|
|
19
19
|
siteSubscriptionsQueryKeyPrefix,
|
|
20
|
+
subscriptionsCountQueryKeyPrefix,
|
|
20
21
|
usePendingPostSubscriptionsQuery,
|
|
21
22
|
usePendingSiteSubscriptionsQuery,
|
|
22
23
|
usePostSubscriptionsQuery,
|
|
@@ -29,6 +30,7 @@ import {
|
|
|
29
30
|
export const SubscriptionManager = {
|
|
30
31
|
SiteSubscriptionsQueryPropsProvider,
|
|
31
32
|
siteSubscriptionsQueryKeyPrefix,
|
|
33
|
+
subscriptionsCountQueryKeyPrefix,
|
|
32
34
|
useCacheKey,
|
|
33
35
|
useIsLoggedIn,
|
|
34
36
|
usePendingPostConfirmMutation,
|
|
@@ -63,8 +65,4 @@ export {
|
|
|
63
65
|
SiteSubscriptionsSortBy,
|
|
64
66
|
} from './constants';
|
|
65
67
|
export { callApi, isErrorResponse, isSiteSubscriptionDetails, isValidId } from './helpers';
|
|
66
|
-
export { UnsubscribedFeedsSearchProvider, useUnsubscribedFeedsSearch } from './contexts';
|
|
67
|
-
export { useReadFeedSearchQuery, useReadFeedSiteQuery, useReadFeedQuery } from './queries';
|
|
68
|
-
|
|
69
68
|
export * from './types';
|
|
70
|
-
export type { FeedItem } from './queries';
|
|
@@ -0,0 +1,208 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @jest-environment jsdom
|
|
3
|
+
*/
|
|
4
|
+
import {
|
|
5
|
+
getSiteSubscriptionsQueryKey,
|
|
6
|
+
type SiteSubscriptionsInfiniteData,
|
|
7
|
+
} from '@automattic/api-queries';
|
|
8
|
+
import { QueryClient, QueryClientProvider } from '@tanstack/react-query';
|
|
9
|
+
import { act, renderHook, waitFor } from '@testing-library/react';
|
|
10
|
+
import React from 'react';
|
|
11
|
+
import { callApi } from '../../helpers';
|
|
12
|
+
import useSiteSubscribeMutation from '../../mutations/use-site-subscribe-mutation';
|
|
13
|
+
import useSiteUnsubscribeMutation from '../../mutations/use-site-unsubscribe-mutation';
|
|
14
|
+
import type { SiteSubscriptionItem } from '../../types';
|
|
15
|
+
import type { ReactNode } from 'react';
|
|
16
|
+
|
|
17
|
+
jest.mock( '../../hooks', () => ( {
|
|
18
|
+
useIsLoggedIn: jest.fn().mockReturnValue( { isLoggedIn: true, id: 1 } ),
|
|
19
|
+
useCacheKey: jest.fn( ( key ) => [ ...key, true, 1 ] ),
|
|
20
|
+
} ) );
|
|
21
|
+
|
|
22
|
+
jest.mock( '../../helpers', () => ( {
|
|
23
|
+
...jest.requireActual( '../../helpers' ),
|
|
24
|
+
callApi: jest.fn(),
|
|
25
|
+
} ) );
|
|
26
|
+
|
|
27
|
+
const makeQueryClient = () => new QueryClient( { defaultOptions: { queries: { retry: false } } } );
|
|
28
|
+
|
|
29
|
+
const makeWrapper = ( queryClient: QueryClient ) =>
|
|
30
|
+
function Wrapper( { children }: { children: ReactNode } ) {
|
|
31
|
+
return <QueryClientProvider client={ queryClient }>{ children }</QueryClientProvider>;
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
const makeSubscription = (
|
|
35
|
+
overrides: Partial< SiteSubscriptionItem > = {}
|
|
36
|
+
): SiteSubscriptionItem => ( {
|
|
37
|
+
ID: 123,
|
|
38
|
+
URL: 'https://example.com',
|
|
39
|
+
feed_URL: 'https://example.com/feed',
|
|
40
|
+
blog_ID: 123,
|
|
41
|
+
feed_ID: 456,
|
|
42
|
+
is_following: true,
|
|
43
|
+
isDeleted: false,
|
|
44
|
+
...overrides,
|
|
45
|
+
} );
|
|
46
|
+
|
|
47
|
+
const makeSiteSubscriptionsData = (
|
|
48
|
+
subscriptions: SiteSubscriptionItem[],
|
|
49
|
+
totalCount = subscriptions.length
|
|
50
|
+
): SiteSubscriptionsInfiniteData => ( {
|
|
51
|
+
pages: [
|
|
52
|
+
{
|
|
53
|
+
subscriptions,
|
|
54
|
+
totalCount,
|
|
55
|
+
page: 1,
|
|
56
|
+
number: 200,
|
|
57
|
+
},
|
|
58
|
+
],
|
|
59
|
+
pageParams: [ 1 ],
|
|
60
|
+
} );
|
|
61
|
+
|
|
62
|
+
const getCachedSubscriptions = ( queryClient: QueryClient ) =>
|
|
63
|
+
queryClient.getQueryData< SiteSubscriptionsInfiniteData >( getSiteSubscriptionsQueryKey() )
|
|
64
|
+
?.pages[ 0 ];
|
|
65
|
+
|
|
66
|
+
describe( 'site subscription mutations', () => {
|
|
67
|
+
beforeEach( () => {
|
|
68
|
+
jest.clearAllMocks();
|
|
69
|
+
} );
|
|
70
|
+
|
|
71
|
+
it( 'optimistically restores a deleted site subscription and increments total count', async () => {
|
|
72
|
+
const queryClient = makeQueryClient();
|
|
73
|
+
queryClient.setQueryData(
|
|
74
|
+
getSiteSubscriptionsQueryKey(),
|
|
75
|
+
makeSiteSubscriptionsData(
|
|
76
|
+
[ makeSubscription( { is_following: false, isDeleted: true } ) ],
|
|
77
|
+
0
|
|
78
|
+
)
|
|
79
|
+
);
|
|
80
|
+
( callApi as jest.Mock ).mockResolvedValue( { subscribed: true } );
|
|
81
|
+
|
|
82
|
+
const { result } = renderHook( () => useSiteSubscribeMutation(), {
|
|
83
|
+
wrapper: makeWrapper( queryClient ),
|
|
84
|
+
} );
|
|
85
|
+
|
|
86
|
+
act( () => {
|
|
87
|
+
result.current.mutate( {
|
|
88
|
+
blog_id: 123,
|
|
89
|
+
url: 'https://example.com/feed',
|
|
90
|
+
doNotInvalidateSiteSubscriptions: true,
|
|
91
|
+
} );
|
|
92
|
+
} );
|
|
93
|
+
|
|
94
|
+
await waitFor( () => expect( callApi ).toHaveBeenCalled() );
|
|
95
|
+
const page = getCachedSubscriptions( queryClient );
|
|
96
|
+
expect( page?.totalCount ).toBe( 1 );
|
|
97
|
+
expect( page?.subscriptions[ 0 ] ).toMatchObject( {
|
|
98
|
+
is_following: true,
|
|
99
|
+
isDeleted: false,
|
|
100
|
+
} );
|
|
101
|
+
} );
|
|
102
|
+
|
|
103
|
+
it( 'rolls back site subscription restore when subscribe fails', async () => {
|
|
104
|
+
const queryClient = makeQueryClient();
|
|
105
|
+
const previousData = makeSiteSubscriptionsData(
|
|
106
|
+
[ makeSubscription( { is_following: false, isDeleted: true } ) ],
|
|
107
|
+
0
|
|
108
|
+
);
|
|
109
|
+
queryClient.setQueryData( getSiteSubscriptionsQueryKey(), previousData );
|
|
110
|
+
( callApi as jest.Mock ).mockRejectedValue( new Error( 'subscribe failed' ) );
|
|
111
|
+
|
|
112
|
+
const { result } = renderHook( () => useSiteSubscribeMutation(), {
|
|
113
|
+
wrapper: makeWrapper( queryClient ),
|
|
114
|
+
} );
|
|
115
|
+
|
|
116
|
+
act( () => {
|
|
117
|
+
result.current.mutate( {
|
|
118
|
+
blog_id: 123,
|
|
119
|
+
url: 'https://example.com/feed',
|
|
120
|
+
doNotInvalidateSiteSubscriptions: true,
|
|
121
|
+
} );
|
|
122
|
+
} );
|
|
123
|
+
|
|
124
|
+
await waitFor( () => expect( result.current.isError ).toBe( true ) );
|
|
125
|
+
expect( queryClient.getQueryData( getSiteSubscriptionsQueryKey() ) ).toEqual( previousData );
|
|
126
|
+
} );
|
|
127
|
+
|
|
128
|
+
it( 'optimistically marks a site subscription deleted and decrements total count', async () => {
|
|
129
|
+
const queryClient = makeQueryClient();
|
|
130
|
+
queryClient.setQueryData(
|
|
131
|
+
getSiteSubscriptionsQueryKey(),
|
|
132
|
+
makeSiteSubscriptionsData( [ makeSubscription() ], 1 )
|
|
133
|
+
);
|
|
134
|
+
( callApi as jest.Mock ).mockResolvedValue( { subscribed: false } );
|
|
135
|
+
|
|
136
|
+
const { result } = renderHook( () => useSiteUnsubscribeMutation(), {
|
|
137
|
+
wrapper: makeWrapper( queryClient ),
|
|
138
|
+
} );
|
|
139
|
+
|
|
140
|
+
act( () => {
|
|
141
|
+
result.current.mutate( {
|
|
142
|
+
subscriptionId: 123,
|
|
143
|
+
blog_id: 123,
|
|
144
|
+
doNotInvalidateSiteSubscriptions: true,
|
|
145
|
+
} );
|
|
146
|
+
} );
|
|
147
|
+
|
|
148
|
+
await waitFor( () => expect( callApi ).toHaveBeenCalled() );
|
|
149
|
+
const page = getCachedSubscriptions( queryClient );
|
|
150
|
+
expect( page?.totalCount ).toBe( 0 );
|
|
151
|
+
expect( page?.subscriptions[ 0 ] ).toMatchObject( {
|
|
152
|
+
is_following: false,
|
|
153
|
+
isDeleted: true,
|
|
154
|
+
resubscribed: false,
|
|
155
|
+
} );
|
|
156
|
+
} );
|
|
157
|
+
|
|
158
|
+
it( 'does not decrement total count when unsubscribe cannot match a cached subscription', async () => {
|
|
159
|
+
const queryClient = makeQueryClient();
|
|
160
|
+
queryClient.setQueryData(
|
|
161
|
+
getSiteSubscriptionsQueryKey(),
|
|
162
|
+
makeSiteSubscriptionsData( [ makeSubscription( { ID: 456, blog_ID: 456 } ) ], 1 )
|
|
163
|
+
);
|
|
164
|
+
( callApi as jest.Mock ).mockResolvedValue( { subscribed: false } );
|
|
165
|
+
|
|
166
|
+
const { result } = renderHook( () => useSiteUnsubscribeMutation(), {
|
|
167
|
+
wrapper: makeWrapper( queryClient ),
|
|
168
|
+
} );
|
|
169
|
+
|
|
170
|
+
act( () => {
|
|
171
|
+
result.current.mutate( {
|
|
172
|
+
subscriptionId: 123,
|
|
173
|
+
blog_id: 123,
|
|
174
|
+
doNotInvalidateSiteSubscriptions: true,
|
|
175
|
+
} );
|
|
176
|
+
} );
|
|
177
|
+
|
|
178
|
+
await waitFor( () => expect( callApi ).toHaveBeenCalled() );
|
|
179
|
+
const page = getCachedSubscriptions( queryClient );
|
|
180
|
+
expect( page?.totalCount ).toBe( 1 );
|
|
181
|
+
expect( page?.subscriptions[ 0 ] ).toMatchObject( {
|
|
182
|
+
is_following: true,
|
|
183
|
+
isDeleted: false,
|
|
184
|
+
} );
|
|
185
|
+
} );
|
|
186
|
+
|
|
187
|
+
it( 'rolls back site subscription delete when unsubscribe fails', async () => {
|
|
188
|
+
const queryClient = makeQueryClient();
|
|
189
|
+
const previousData = makeSiteSubscriptionsData( [ makeSubscription() ], 1 );
|
|
190
|
+
queryClient.setQueryData( getSiteSubscriptionsQueryKey(), previousData );
|
|
191
|
+
( callApi as jest.Mock ).mockRejectedValue( new Error( 'unsubscribe failed' ) );
|
|
192
|
+
|
|
193
|
+
const { result } = renderHook( () => useSiteUnsubscribeMutation(), {
|
|
194
|
+
wrapper: makeWrapper( queryClient ),
|
|
195
|
+
} );
|
|
196
|
+
|
|
197
|
+
act( () => {
|
|
198
|
+
result.current.mutate( {
|
|
199
|
+
subscriptionId: 123,
|
|
200
|
+
blog_id: 123,
|
|
201
|
+
doNotInvalidateSiteSubscriptions: true,
|
|
202
|
+
} );
|
|
203
|
+
} );
|
|
204
|
+
|
|
205
|
+
await waitFor( () => expect( result.current.isError ).toBe( true ) );
|
|
206
|
+
expect( queryClient.getQueryData( getSiteSubscriptionsQueryKey() ) ).toEqual( previousData );
|
|
207
|
+
} );
|
|
208
|
+
} );
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
+
import { getSiteSubscriptionsQueryKey } from '@automattic/api-queries';
|
|
1
2
|
import { useMutation, useQueryClient } from '@tanstack/react-query';
|
|
2
3
|
import { callApi } from '../helpers';
|
|
3
4
|
import { useCacheKey, useIsLoggedIn } from '../hooks';
|
|
4
|
-
import { siteSubscriptionsQueryKeyPrefix } from '../queries';
|
|
5
5
|
import { subscriptionsCountQueryKeyPrefix } from '../queries/use-subscriptions-count-query';
|
|
6
6
|
import { PendingSiteSubscriptionsResult, SubscriptionManagerSubscriptionsCount } from '../types';
|
|
7
7
|
|
|
@@ -17,7 +17,7 @@ type PendingSiteConfirmResponse = {
|
|
|
17
17
|
const usePendingSiteConfirmMutation = () => {
|
|
18
18
|
const { isLoggedIn } = useIsLoggedIn();
|
|
19
19
|
const queryClient = useQueryClient();
|
|
20
|
-
const subscriptionsCacheKey =
|
|
20
|
+
const subscriptionsCacheKey = getSiteSubscriptionsQueryKey();
|
|
21
21
|
const countCacheKey = useCacheKey( subscriptionsCountQueryKeyPrefix );
|
|
22
22
|
|
|
23
23
|
return useMutation( {
|
|
@@ -1,16 +1,16 @@
|
|
|
1
|
+
import {
|
|
2
|
+
getSiteSubscriptionsQueryKey,
|
|
3
|
+
type SiteSubscriptionsInfiniteData,
|
|
4
|
+
} from '@automattic/api-queries';
|
|
1
5
|
import { useMutation, useQueryClient } from '@tanstack/react-query';
|
|
2
6
|
import { EmailDeliveryFrequency } from '../constants';
|
|
3
|
-
import { callApi
|
|
7
|
+
import { callApi } from '../helpers';
|
|
4
8
|
import {
|
|
5
9
|
alterSiteSubscriptionDetails,
|
|
6
10
|
invalidateSiteSubscriptionDetails,
|
|
7
11
|
} from '../helpers/optimistic-update';
|
|
8
12
|
import { useIsLoggedIn } from '../hooks';
|
|
9
|
-
import type {
|
|
10
|
-
PagedQueryResult,
|
|
11
|
-
SiteSubscriptionsResponseItem,
|
|
12
|
-
SiteSubscriptionDetails,
|
|
13
|
-
} from '../types';
|
|
13
|
+
import type { SiteSubscriptionDetails } from '../types';
|
|
14
14
|
|
|
15
15
|
type SiteSubscriptionDeliveryFrequencyParams = {
|
|
16
16
|
delivery_frequency: EmailDeliveryFrequency;
|
|
@@ -63,39 +63,35 @@ const useSiteDeliveryFrequencyMutation = () => {
|
|
|
63
63
|
return response;
|
|
64
64
|
},
|
|
65
65
|
onMutate: async ( { blog_id, delivery_frequency, subscriptionId } ) => {
|
|
66
|
-
const siteSubscriptionsCacheKey =
|
|
67
|
-
[ 'read', 'site-subscriptions' ],
|
|
68
|
-
isLoggedIn,
|
|
69
|
-
id
|
|
70
|
-
);
|
|
66
|
+
const siteSubscriptionsCacheKey = getSiteSubscriptionsQueryKey();
|
|
71
67
|
|
|
72
68
|
await queryClient.cancelQueries( { queryKey: siteSubscriptionsCacheKey } );
|
|
73
69
|
|
|
74
70
|
const previousSiteSubscriptions =
|
|
75
|
-
queryClient.getQueryData<
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
71
|
+
queryClient.getQueryData< SiteSubscriptionsInfiniteData >( siteSubscriptionsCacheKey );
|
|
72
|
+
const mutatedSiteSubscriptions = previousSiteSubscriptions
|
|
73
|
+
? {
|
|
74
|
+
...previousSiteSubscriptions,
|
|
75
|
+
pages: previousSiteSubscriptions.pages.map( ( page ) => ( {
|
|
76
|
+
...page,
|
|
77
|
+
subscriptions: page.subscriptions.map( ( siteSubscription ) => {
|
|
78
|
+
if ( Number( siteSubscription.blog_ID ) === Number( blog_id ) ) {
|
|
79
|
+
return {
|
|
80
|
+
...siteSubscription,
|
|
81
|
+
delivery_methods: {
|
|
82
|
+
...siteSubscription.delivery_methods,
|
|
83
|
+
email: {
|
|
84
|
+
...( siteSubscription.delivery_methods?.email ?? { send_posts: false } ),
|
|
85
|
+
post_delivery_frequency: delivery_frequency,
|
|
86
|
+
},
|
|
87
|
+
},
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
return siteSubscription;
|
|
91
|
+
} ),
|
|
92
|
+
} ) ),
|
|
93
|
+
}
|
|
94
|
+
: previousSiteSubscriptions;
|
|
99
95
|
queryClient.setQueryData( siteSubscriptionsCacheKey, mutatedSiteSubscriptions );
|
|
100
96
|
|
|
101
97
|
const previousSiteSubscriptionDetails = await alterSiteSubscriptionDetails(
|
|
@@ -122,7 +118,7 @@ const useSiteDeliveryFrequencyMutation = () => {
|
|
|
122
118
|
},
|
|
123
119
|
onError: ( err, _, context ) => {
|
|
124
120
|
queryClient.setQueryData(
|
|
125
|
-
|
|
121
|
+
getSiteSubscriptionsQueryKey(),
|
|
126
122
|
context?.previousSiteSubscriptions
|
|
127
123
|
);
|
|
128
124
|
if ( context?.previousSiteSubscriptionDetails ) {
|
|
@@ -1,11 +1,15 @@
|
|
|
1
|
+
import {
|
|
2
|
+
getSiteSubscriptionsQueryKey,
|
|
3
|
+
type SiteSubscriptionsInfiniteData,
|
|
4
|
+
} from '@automattic/api-queries';
|
|
1
5
|
import { useMutation, useQueryClient } from '@tanstack/react-query';
|
|
2
|
-
import {
|
|
6
|
+
import { callApi } from '../helpers';
|
|
3
7
|
import {
|
|
4
8
|
alterSiteSubscriptionDetails,
|
|
5
9
|
invalidateSiteSubscriptionDetails,
|
|
6
10
|
} from '../helpers/optimistic-update';
|
|
7
11
|
import { useIsLoggedIn } from '../hooks';
|
|
8
|
-
import type {
|
|
12
|
+
import type { SiteSubscriptionDetails } from '../types';
|
|
9
13
|
|
|
10
14
|
type SiteSubscriptionEmailMeNewCommentsParams = {
|
|
11
15
|
send_comments: boolean;
|
|
@@ -50,16 +54,12 @@ const useSiteEmailMeNewCommentsMutation = () => {
|
|
|
50
54
|
return response;
|
|
51
55
|
},
|
|
52
56
|
onMutate: async ( { blog_id, send_comments, subscriptionId } ) => {
|
|
53
|
-
const siteSubscriptionsQueryKey =
|
|
54
|
-
[ 'read', 'site-subscriptions' ],
|
|
55
|
-
isLoggedIn,
|
|
56
|
-
id
|
|
57
|
-
);
|
|
57
|
+
const siteSubscriptionsQueryKey = getSiteSubscriptionsQueryKey();
|
|
58
58
|
|
|
59
59
|
await queryClient.cancelQueries( { queryKey: siteSubscriptionsQueryKey } );
|
|
60
60
|
|
|
61
61
|
const previousSiteSubscriptions =
|
|
62
|
-
queryClient.getQueryData<
|
|
62
|
+
queryClient.getQueryData< SiteSubscriptionsInfiniteData >( siteSubscriptionsQueryKey );
|
|
63
63
|
|
|
64
64
|
if ( previousSiteSubscriptions ) {
|
|
65
65
|
queryClient.setQueryData( siteSubscriptionsQueryKey, {
|
|
@@ -68,7 +68,7 @@ const useSiteEmailMeNewCommentsMutation = () => {
|
|
|
68
68
|
return {
|
|
69
69
|
...page,
|
|
70
70
|
subscriptions: page.subscriptions.map( ( siteSubscription ) => {
|
|
71
|
-
if ( siteSubscription.blog_ID === blog_id ) {
|
|
71
|
+
if ( Number( siteSubscription.blog_ID ) === Number( blog_id ) ) {
|
|
72
72
|
return {
|
|
73
73
|
...siteSubscription,
|
|
74
74
|
delivery_methods: {
|
|
@@ -112,7 +112,7 @@ const useSiteEmailMeNewCommentsMutation = () => {
|
|
|
112
112
|
onError: ( _err, _, context ) => {
|
|
113
113
|
if ( context?.previousSiteSubscriptions ) {
|
|
114
114
|
queryClient.setQueryData(
|
|
115
|
-
|
|
115
|
+
getSiteSubscriptionsQueryKey(),
|
|
116
116
|
context.previousSiteSubscriptions
|
|
117
117
|
);
|
|
118
118
|
}
|