Commit Graph

1148 Commits

Author SHA1 Message Date
Fabien O'Carroll
c2f85d3742 Used isEqual to compare ValueObjects
no-issue

This ensures that ValueObjects can contain non-primitive types.
2021-10-14 14:56:37 +02:00
Fabien O'Carroll
3fc4bf6239 Published new versions
- @tryghost/members-api@2.2.2
 - @tryghost/members-offers@0.6.1
2021-10-14 12:06:48 +02:00
Fabien O'Carroll
53d24e501d Fixed Stripe Checkout using Offers
refs https://github.com/TryGhost/Members/commit/5172e40646

When we updated to use the OffersAPI instead of OfferRepository this was
missed, and we were passing blank coupon to Stripe Checkout. This should
eventually be replaced with a call like `getCoupon(offerId)` from a
payments service.
2021-10-14 12:02:39 +02:00
Fabien O'Carroll
2a3df8e3db Published new versions
- @tryghost/members-api@2.2.1
2021-10-13 11:22:05 +02:00
Fabien O'Carroll
9e7891fef7 Restricted archived Offers from being used
refs https://github.com/TryGhost/Team/issues/1133

An archived Offer is intended to be disabled from a redemption point of
view. This ensures that we do not allow Stripe Checkout Sessions to be
created for them.
2021-10-13 11:19:35 +02:00
Fabien O'Carroll
1ec3dfbfab Published new versions
- @tryghost/members-api@2.2.0
2021-10-13 11:16:08 +02:00
Fabien O'Carroll
5172e40646 Used OffersAPI over OfferRepository in MembersAPI
no-issue

The OfferRepository deals with domain objects in the Offers module, and
as such is not suitable for use with "external" services. This update
means that MembersAPI can deal with POJO DTOs so that there is not a
dependency on the internals of the Offers module. Just on the contract
it holds with the outside world.
2021-10-13 11:11:12 +02:00
Fabien O'Carroll
8ef752a7f7 Published new versions
- @tryghost/members-offers@0.6.0
2021-10-12 18:36:47 +02:00
Fabien O'Carroll
96e87d6798 Ensured that Offers can be filtered on status
refs https://github.com/TryGhost/Team/issues/1131

This adds a mapping between the status property used in the domain & API
and the active column used in the database. As we only have the usecase
of filtering by `status` right now, we have not added support for all
the other columns. Instead of these potentially erroring where the
column name does not match the property name in the domain/api - we've
added a transformer which will ignore all filters for properties other
than `status`. This follows postels law, in that we can be liberal with
the filters we accept, but conservative in the ones we implement.
2021-10-12 18:36:04 +02:00
Fabien O'Carroll
cf8fcc6f35 Installed @nexes/mongo-utils
refs https://github.com/TryGhost/Team/issues/1131

This will allow us to map filters from our domain to the persistence
layer.
2021-10-12 18:32:48 +02:00
Fabien O'Carroll
1e4b5c792a Supported using NQL filter to get Offers
refs https://github.com/TryGhost/Team/issues/1131

This adds initial support for pass through a filter to the Model layer,
so that we can fetch Offers based on an NQL filter.
2021-10-12 18:32:48 +02:00
Naz
8b271835d2 Published new versions
- @tryghost/express-dynamic-redirects@0.2.0
2021-10-12 17:26:29 +02:00
Naz
4da8051114 Fixed tests
refs https://linear.app/tryghost/issue/CORE-84/have-a-look-at-the-eggs-redirects-refactor-branch
refs c44e33b1f7

- Previous commit didn't adjust unit tests to the new constructor API
2021-10-12 17:25:52 +02:00
Naz
c44e33b1f7 Simplified DynamicRedirectManager's constructor interface
refs https://linear.app/tryghost/issue/CORE-84/have-a-look-at-the-eggs-redirects-refactor-branch

- There is no need to pass in whole "urlUtils" instance to construct the class as all the class has to know is how to construct a "subdirectory URL" which can be a single function passed in instead of a vague object instance
2021-10-12 17:21:46 +02:00
Naz
ba2a5df493 Added handling for invalid redirect regexes
refs https://linear.app/tryghost/issue/CORE-84/have-a-look-at-the-eggs-redirects-refactor-branch
refs 8f5186995d
refs 260a47da83

- The router should not stop working when an invalid redirect definition is added
- Referenced commits solve this exact problem before this module was introduced
2021-10-12 17:21:46 +02:00
Naz
80f2a001ec Simplified DynamicRedirectManager's constructor interface
refs https://linear.app/tryghost/issue/CORE-84/have-a-look-at-the-eggs-redirects-refactor-branch

- In most of the packages we follow the pattern of passing in a single "options" object into a constructor and desructuring those the object into parameter, like this example: 077c83dc2d/packages/limit-service/lib/limit-service.js (L19-L26)
2021-10-12 17:21:46 +02:00
Fabien O'Carroll
73e11690c1 Published new versions
- @tryghost/members-offers@0.5.0
2021-10-12 17:14:11 +02:00
Fabien O'Carroll
facbfcfa8e Added support for Offer status to API
refs https://github.com/TryGhost/Team/issues/1131

- Includes `status` on OfferDTO so client can use it
- Allows editing `status` of Offers
- Allows setting initial `status` when creating Offers
2021-10-12 17:11:54 +02:00
Fabien O'Carroll
04b9944e67 Defaulted to 'active' status when creating Offers
refs https://github.com/TryGhost/Team/issues/1131

This ensures that Offers are active by default.
2021-10-12 17:10:51 +02:00
Fabien O'Carroll
a772f5b82f Wired up Offer status to the OfferRepository
refs https://github.com/TryGhost/Team/issues/1131

This allows us to persist and hydrate the Offer status from our
database.
2021-10-12 15:29:13 +02:00
Fabien O'Carroll
1f936357d9 Added concept of OfferStatus to domain model
refs https://github.com/TryGhost/Team/issues/1131

This allows us to model the behaviour of archived & active offers, as
well as allowing us to set their status on the model.
2021-10-12 15:27:27 +02:00
Fabien O'Carroll
d148108ae6 Published new versions
- @tryghost/members-api@2.1.1
 - @tryghost/members-offers@0.4.2
2021-10-08 15:21:07 +02:00
Fabien O'Carroll
afa5363dd4 Fixed Stripe Checkout for monthly Offers
refs https://github.com/TryGhost/Members/commit/504fb1bf

Since we updated the Offer to use Value Objects, we needed to update the
usage here too.
2021-10-08 15:19:59 +02:00
Fabien O'Carroll
1312943f5b Updated Offer to only change code once
no-issue

This simplifies the handling of updating redirects for a code, and
doesn't affect our application layer because we never have the need to
change a code twice.

In future this should be replaced with events at the domain level - so
that we do not have to track changed properties and instead a redirect
service can listen to events, which would be dispatched on a successful
save by the repository.
2021-10-08 13:02:22 +02:00
Fabien O'Carroll
1f703920c9 Published new versions
- @tryghost/members-offers@0.4.1
2021-10-08 12:43:16 +02:00
Fabien O'Carroll
08d3e6e99c Allowed for OfferDescription to be null/empty
refs https://github.com/TryGhost/Team/issues/1083

OfferDescription is not a required field, so we must not throw when it
is falsy or not present.
2021-10-08 12:40:57 +02:00
Fabien O'Carroll
35f150bcf4 Moved errors to domain/errors
no-issue

More cleanup to pull files into their appropriate responsibility
2021-10-08 12:31:11 +02:00
Fabien O'Carroll
9bcd25fe5e Moved application concerns to an application dir
no-issue

Shuffling files to give a better idea of what the files concern, as well
as to add some structure.
2021-10-08 12:27:17 +02:00
Fabien O'Carroll
78be4b55c9 Moved ValueObject to domain/models/shared
no-issue

This is only ever used in this directory so it makes sense to be
colocated.
2021-10-08 12:23:40 +02:00
Fabien O'Carroll
4a27ef68df Moved events into domain directory
no-issue

Events are a domain concern and as such should live in this directory
2021-10-08 12:21:27 +02:00
Fabien O'Carroll
32a88df1d3 Published new versions
- @tryghost/members-offers@0.4.0
2021-10-08 12:13:38 +02:00
Fabien O'Carroll
9f7a922415 Added support for "repeating" duration Offers
refs https://github.com/TryGhost/Team/issues/1083

We combine the duration and duration_in_months into a single value
object which can be validated together, meaning we will never have
properties which are out of sync (e.g. forever durations with 2 months).
2021-10-08 12:10:36 +02:00
Fabien O'Carroll
6afb1eae40 Published new versions
- @tryghost/members-offers@0.3.5
2021-10-08 11:41:07 +02:00
Fabien O'Carroll
bd3f1e6456 Fixed sending back currency for Fixed Offers
no-issue

Since we changed the type from "amount" to "fixed" the logic to send
back the currency was not working. This updates it to use the correct
values.
2021-10-08 11:38:47 +02:00
Fabien O'Carroll
a5f4698201 Published new versions
- @tryghost/members-offers@0.3.4
2021-10-07 18:21:52 +02:00
Fabien O'Carroll
c8933c9abd Fixed handling of null currency & used duration
no-issue

Currency is not always present on an offer so we need to handle it.
Duration was incorrectly not passed to Stripe when creating the coupon.
2021-10-07 18:18:53 +02:00
Fabien O'Carroll
13b870d0ef Published new versions
- @tryghost/members-offers@0.3.3
2021-10-07 17:42:52 +02:00
Fabien O'Carroll
170591a113 Improved types for Offer
no-issue

This splits out the types of the Offers properties from the types of the
expected values to be passed to create.
2021-10-07 17:37:48 +02:00
Fabien O'Carroll
2b58ecd82e Added support for creating fixed offers with currency
refs https://github.com/TryGhost/Team/issues/1083

We now allow creating offers for a fixed amount, rather than a
percentage. These require a currency to be passed as a fixed amount is
meaningless without one.
2021-10-07 17:37:48 +02:00
Fabien O'Carroll
2c04afe810 Updated types of Offers to "fixed" and "percent"
no-issue

This is inline with the language used elsewhere to describe these types.
2021-10-07 17:35:34 +02:00
Fabien O'Carroll
6d383c2d0e Added support for "once" and "forever" Offer duration
refs https://github.com/TryGhost/Team/issues/1083

Instead of Offers being hardcoded to the "once" duration this will allow
Admins to start creating offers of variable durations.
2021-10-07 17:13:23 +02:00
Fabien O'Carroll
ea0282c80e Published new versions
- @tryghost/members-offers@0.3.2
2021-10-07 16:46:52 +02:00
Fabien O'Carroll
504fb1bfa1 Used Value Objects to validate outside of Offer factory
no-issue

This adds the concept of "Value Objects" to an Offers properties,
allowing us to move validation out and ensure that an Offer will only
ever have valid properties, without having to duplicate checks - or
leave them to the persistent layer. This means we can fail early, as
well as write unit tests for all of our validation.
2021-10-07 16:46:08 +02:00
Fabien O'Carroll
a673b2ae99 Published new versions
- @tryghost/members-offers@0.3.1
2021-10-07 12:47:03 +02:00
Fabien O'Carroll
d9e40c6070 Ensured Offer code is slugified
refs https://github.com/TryGhost/Team/issues/1083

This ensures that the code will be URL safe for redirects
2021-10-07 12:45:51 +02:00
Fabien O'Carroll
309e827a7f Published new versions
- @tryghost/members-api@2.1.0
 - @tryghost/members-offers@0.3.0
2021-10-06 16:55:51 +02:00
Fabien O'Carroll
6ae8b7eb0c Added stripeCouponId to Offer
refs https://github.com/TryGhost/Team/issues/1090

When creating a Stripe Checkout Session for an Offer - we need access to
the underlying Stripe Coupon. Exposing it here allows consumers of the
OfferRepository access.
2021-10-06 16:12:53 +02:00
Fabien O'Carroll
f0141f08ff Applied Offers when creating Stripe Checkout Session
refs https://github.com/TryGhost/Team/issues/1090

Instead of the hardcoded 1-day version for Offers, we can now talk
directly to the Offers repository and use the real values for Stripe
Checkout.
2021-10-06 16:12:53 +02:00
Fabien O'Carroll
d57d082c39 Exposed OfferRepository from OffersModule
refs https://github.com/TryGhost/Team/issues/1090

When creating checkout session we will need to be able to look up Offers
from the OfferRepository. This exposes the repository so that it can be
passed as a dependency elsewhere.
2021-10-06 15:15:03 +02:00
Fabien O'Carroll
371581f677 Published new versions
- @tryghost/members-offers@0.2.1
2021-10-06 12:08:48 +02:00
Fabien O'Carroll
dbc7d73be7 Fixed updateOffer API method
no-issue

- Property names were out of sync with API
- Async methods were not awaited
- Transaction was erroneously commited
2021-10-06 12:07:03 +02:00
Fabien O'Carroll
6397438e73 Published new versions
- @tryghost/members-offers@0.2.0
2021-10-05 16:27:31 +02:00
Fabien O'Carroll
33d042ccf7 Added getOffer method to OffersAPI
refs https://github.com/TryGhost/Team/issues/1083
2021-10-05 16:25:56 +02:00
Fabien O'Carroll
b3ed676e53 Moved redirect handling outside of repository
no-issue

The redirect handling is more of an application concern that can happen
at the top level, rather than the lower level of the repository.
2021-10-05 16:24:47 +02:00
Fabien O'Carroll
d4ed604cce Published new versions
- @tryghost/members-offers@0.1.2
2021-10-05 13:15:47 +02:00
Fabien O'Carroll
5dd5b71718 Fixed redirects for new offers
refs https://github.com/TryGhost/Team/issues/1091
2021-10-05 13:14:33 +02:00
Fabien O'Carroll
587954faf9 Published new versions
- @tryghost/members-offers@0.1.1
2021-10-05 11:44:32 +02:00
Fabien O'Carroll
ef73121ae4 Fixed UniqueChecker methods
no-issue

These were returning the opposite of what they should have.
2021-10-05 11:43:38 +02:00
Fabien O'Carroll
81badcae2e Published new versions
- @tryghost/members-offers@0.1.0
2021-10-05 11:19:44 +02:00
Fabien O'Carroll
5674036902 Added initial Offers module
refs https://github.com/TryGhost/Team/issues/1083

This is the initial scaffolding for setting up Offers in Ghost
2021-10-05 11:19:15 +02:00
Fabien O'Carroll
b03221401e Published new versions
- @tryghost/members-api@2.0.0
2021-10-04 13:35:10 +02:00
Fabien 'egg' O'Carroll
c5784da2b6 Updated MembersAPI to take StripeAPIService as dep (#338)
refs https://github.com/TryGhost/Team/issues/1083

The Offers service is going to need access to the StripeAPIService too,
so we must pull its initialisation out of this module up to the Ghost
application layer, which will allow us to pass a reference of the
StripeAPIService to wherever needs it.
2021-10-04 13:34:17 +02:00
Fabien O'Carroll
9341c318d3 Published new versions
- @tryghost/members-api@1.39.1
 - @tryghost/members-stripe-service@0.3.0
2021-10-01 13:18:02 +02:00
Fabien O'Carroll
515a50f2a4 Updated subscription price changes to always invoice
refs https://github.com/TryGhost/Team/issues/1075

Without this flag, payment for upgrading to a more expensive plan will
be taken at the end of the current billing cycle, which could be a year
from the date of the switch - this would effectively give free access to
more expensive prices.
2021-10-01 12:27:09 +02:00
Fabien O'Carroll
a438795d4a Published new versions
- @tryghost/express-dynamic-redirects@0.1.0
2021-09-29 12:02:26 +02:00
Fabien 'egg' O'Carroll
8c92f5744c Added express-dynamic-redirects module (#337)
refs https://github.com/TryGhost/Team/issues/1091

The Offers feature needs to be able to add and remove redirects to Ghost
- which is very similar to the custom redirects functionality. Here we've
pulled out the core of the dynamic redirect part of custom redirects so
that it can be used by both features and have code shared between them.
2021-09-29 12:01:40 +02:00
Fabien O'Carroll
dad54a25b1 Published new versions
- @tryghost/domain-events@0.1.2
 - @tryghost/magic-link@1.0.13
 - @tryghost/member-analytics-service@0.1.2
 - @tryghost/member-events@0.2.1
 - @tryghost/members-analytics-ingress@0.1.3
 - @tryghost/members-api@1.39.0
 - @tryghost/members-csv@1.1.7
 - @tryghost/members-importer@0.3.3
 - @tryghost/members-ssr@1.0.14
 - @tryghost/members-stripe-service@0.2.0
2021-09-28 13:40:14 +02:00
Fabien O'Carroll
cd6e87774a Added 1-day version of Offers
refs https://github.com/TryGhost/Team/issues/1090

This 1-day version of Offers allows us to test the full flow of the
Offers feature without having to implement all of it. The focus here is
that we can pass an Offer ID when creating a Stripe Checkout session and
have it apply. Here we use hardcoded Stripe Coupons as we haven't yet
got persistence implemented for Offers & their related Stripe Coupons
2021-09-28 13:39:04 +02:00
Fabien O'Carroll
e5b0cf8686 Added basic support for coupons
refs https://github.com/TryGhost/Team/issues/1090

This allows us to create Stripe Coupons and use them with Stripe
Checkout from the members-api module whilst we develop the Offers
feature.
2021-09-28 13:39:04 +02:00
Renovate Bot
c13be723e6 Update dependency mocha to v9.1.2 2021-09-28 07:42:20 +00:00
Fabien O'Carroll
2d68442af1 Published new versions
- @tryghost/members-api@1.38.1
2021-09-23 11:16:44 +02:00
Fabien O'Carroll
e93d092766 Fixed handling of invalid tokens when changing email
no-issue

Without a return after ending the response, the code will continue to
attempt to send emails and then send another response which results in
an uncaught error.
2021-09-23 11:12:23 +02:00
Fabien O'Carroll
9031602406 Published new versions
- @tryghost/members-api@1.38.0
2021-09-22 16:50:02 +02:00
Fabien O'Carroll
4e947a88ce Fixed security hole in email address change flow
refs https://github.com/TryGhost/Ghost/security/advisories/GHSA-65p7-pjj8-ggmr

The email address change flow was built on top of the unauthenticated
signin/signup flow. This meant that ownership of the email being changed
wasn't verified and allowed a malicious actore to change the email
address of arbitrary accounts to an email address which they controlled.

We remove the ability to change email addresses from the signin/signup
flow and instead create a dedicated, authenticated flow for changing
email address.
2021-09-22 16:49:17 +02:00
Rishabh
21fbaff41b Published new versions
- @tryghost/members-api@1.37.5
2021-09-22 18:13:43 +05:30
Rishabh
fe4fb78830 Cleaned up stripe-service package usage
no refs

- updates all usages of `stripe-service` package to new correct `members-stripe-service` package
2021-09-22 18:12:40 +05:30
Rishabh
aa0b95528e Published new versions
- @tryghost/members-api@1.37.4
 - @tryghost/members-stripe-service@0.1.0
2021-09-22 18:09:11 +05:30
Rishabh
c21a77cd01 Removed tests temporarily to publish new stripe package
no refs
2021-09-22 18:08:30 +05:30
Rishabh
3e54819469 Revert "Updated usage of stripe-service package to members-stripe-service package"
This reverts commit 7363f0769d.
2021-09-22 18:05:41 +05:30
Rishabh
7363f0769d Updated usage of stripe-service package to members-stripe-service package
refs 8b90c93a79
2021-09-22 18:02:50 +05:30
Rishabh
8b90c93a79 Renamed stripe-service package to members-stripe-service
no refs

- the package `@tryghost/stripe-service` was already published and used in a different context, so this package was never able to get published and the references in Members package are incorrectly pointing to wrong package
- renames the package in members context
2021-09-22 18:00:47 +05:30
Rishabh
dacb1d6fa0 Published new versions
- @tryghost/member-analytics-service@0.1.1
 - @tryghost/members-analytics-ingress@0.1.2
 - @tryghost/members-api@1.37.3
2021-09-22 17:21:49 +05:30
Rishabh
e1d96b5086 Updated missing packages
no refs

- cleans up package usage across new members packages
2021-09-22 17:18:39 +05:30
Rishabh
1c25665e7e Published new versions
- @tryghost/members-api@1.37.2
2021-09-22 16:57:30 +05:30
Rishabh
85db4aa8bd Removed unused packages from members-api
no refs

Cleans up unused package dependencies on members-api
2021-09-22 16:56:28 +05:30
Rishabh
411345ed42 Published new versions
- @tryghost/members-analytics-ingress@0.1.1
 - @tryghost/members-api@1.37.1
2021-09-22 16:53:59 +05:30
Rishabh
37001c539d Fixed lint
no refs
2021-09-22 16:52:40 +05:30
Rishabh
317caacc0e Updated ingress event handler to use new analytics ingress package
refs https://github.com/TryGhost/Team/issues/1064

- updates handling of member events to use new analytics ingress package which is responsible to ensure storage of event
2021-09-22 16:51:03 +05:30
Rishabh
07d65c4741 Added missing package dependencies
no refs

- the package dependencies of modules we use in `members-api` got missed with previous changes, updating
2021-09-22 16:24:54 +05:30
Rishabh
6c109b1080 Published new versions
- @tryghost/members-analytics-ingress@0.1.0
 - @tryghost/members-api@1.37.0
2021-09-22 16:21:27 +05:30
Rishabh Garg
1f7a455374 Added @tryghost/members-analytics-ingress package (#335)
refs https://github.com/TryGhost/Team/issues/1064

This package will be used as to handle and emit ingress events on new members event endpoint - `/members/api/events`
2021-09-22 16:07:37 +05:30
Fabien O'Carroll
71b3a62c79 Published new versions
- @tryghost/domain-events@0.1.1
 - @tryghost/magic-link@1.0.12
 - @tryghost/member-analytics-service@0.1.0
 - @tryghost/member-events@0.2.0
 - @tryghost/members-api@1.36.0
 - @tryghost/members-ssr@1.0.13
2021-09-21 18:42:13 +02:00
Fabien O'Carroll
d12f7cd152 Added listeners for remaining events
refs https://github.com/TryGhost/Team/issues/1054

This adds the missing listeners for the rest of the analytics events
we'd like to capture.
2021-09-21 18:39:17 +02:00
Fabien O'Carroll
9fca7ce8f3 Added missing events for analytics
refs https://github.com/TryGhost/Team/issues/1054

In order to listen to events we must define them! This adds the missing
events that we need to listen to for member analytics.
2021-09-21 18:39:17 +02:00
Fabien O'Carroll
41bdd38237 Wired up member-analytics-service
refs https://github.com/TryGhost/Team/issues/1054

We need to instantiate the MemberAnalyticsService so that we can start
listening to events and storing them, this is the minium glue code
required to get us going.
2021-09-21 13:40:23 +02:00
Fabien O'Carroll
ed6d305fb2 Renamed components of member-analytic-service
no-issue

This removes the concept of "Module" which simplifies the code
2021-09-21 13:33:38 +02:00
Fabien O'Carroll
216d27371a Added initial member-analytics-service
refs https://github.com/TryGhost/Team/issues/1054

This is the initial pass at the analytics service which listens to
events and then handles persisting them via the repository

refs https://github.com/TryGhost/Team/issues/1055

This also adds the analytic event repository which handles persisting
the events.
2021-09-21 13:24:28 +02:00
renovate[bot]
1c4b51ee53 Update dependency @types/node to v14.17.17 (#277)
Co-authored-by: Renovate Bot <bot@renovateapp.com>
2021-09-21 11:23:56 +02:00
renovate[bot]
af32755cbc Update dependency @types/nodemailer to v6.4.4 (#276)
Co-authored-by: Renovate Bot <bot@renovateapp.com>
2021-09-20 13:53:52 +02:00
renovate[bot]
b695e10e3f Pin dependency @babel/eslint-parser to 7.15.4 (#330)
Co-authored-by: Renovate Bot <bot@renovateapp.com>
2021-09-20 13:52:36 +02:00
Fabien O'Carroll
bdd030cce5 Published new versions
- @tryghost/domain-events@0.1.0
 - @tryghost/member-events@0.1.0
 - @tryghost/members-api@1.35.0
2021-09-17 15:25:14 +02:00
Fabien O'Carroll
3f9af4f554 Added @tryghost/member-events
refs https://github.com/TryGhost/Team/issues/1054

This will hold all of the event definitions used in members so that they
can be used across packages.
2021-09-17 15:22:08 +02:00
Fabien O'Carroll
6c01ff2a3d Added @tryghost/domain-events package
refs https://github.com/TryGhost/Team/issues/1054

This package will be used as a singleton for listenig and sending events
throughout the members application.
2021-09-17 15:22:08 +02:00
Fabien 'egg' O'Carroll
528fd23874 Added ability to fetch member by identity token (#329)
refs https://github.com/TryGhost/Team/issues/1057

This method will validate a token, and then return the member associated
with it. Rather than exposing token validation and coupling consumers to
the structure of the token response data.
2021-09-17 11:25:57 +02:00
Fabien O'Carroll
d99e0acf1a Published new versions
- @tryghost/members-api@1.34.0
2021-09-14 13:22:21 +02:00
Fabien 'egg' O'Carroll
1f2750e5c0 Added browse, edit & add methods to MemberBREADService (#326)
refs https://github.com/TryGhost/Team/issues/873

This ensures that all requests to the API will include the mock
subscriptions for comped members. Allowing the Admin to correctly show
the subscription information after adding and editing members. As well
as having the correct information when navigating from the list of
members to an individual member.
2021-09-14 13:18:34 +02:00
Fabien O'Carroll
81f19f4991 Published new versions
- @tryghost/members-api@1.33.0
2021-09-13 14:47:49 +02:00
Fabien O'Carroll
7a401e5253 Used @tryghost/stripe-service in @tryghost/members-api
no-issue

This finalises the extraction of the StripeAPIService to a separate
package!
2021-09-13 14:38:40 +02:00
Fabien O'Carroll
0615da1b45 Published new versions
- @tryghost/stripe-service@0.1.0
2021-09-13 14:37:27 +02:00
Fabien O'Carroll
7e082b7eb5 Added @tryghost/stripe-service
no-issue

This pulls out the StripeService from the @tryghost/members-api package.

The idea is to break the @tryghost/members-api package into smaller
modules, with the hope to make it easier to maintain and reason about.
2021-09-13 14:35:57 +02:00
Fabien O'Carroll
eed346e4ec Published new versions
- @tryghost/members-api@1.32.1
2021-09-08 12:39:51 +02:00
Fabien O'Carroll
00e0c9d205 Fixed webhook handler check for if Stripe configured
no-issue

Previously we would not create an instance of the StripeAPIService if
Stripe was not configured, but that is not the case any more, instead we
have a configured flag on the service. The webhook route handler was not
updated to use this flag and so would attempt to handle webhooks without
having any of the required data. This would result in an uncaught error.
2021-09-08 12:27:09 +02:00
Fabien O'Carroll
a072d19385 Published new versions
- @tryghost/members-api@1.32.0
2021-09-07 18:26:36 +02:00
Fabien O'Carroll
67d2104190 Deleted webhooks when disconnecting from Stripe
refs https://github.com/TryGhost/Team/issues/1006

When disconnecting from Stripe, we currently do not remove the webhooks,
this will result in the webhooks from Stripe failing, and tending toward
a 100% error rate, which will ultimately result in emails from Stripe
about the failing webhook.

In order to stop all of that from happening, we should make sure that we
actively remove the webhook from Stripe when disconnecting.
2021-09-07 18:02:35 +02:00
Fabien O'Carroll
2d394b3a2e Published new versions
- @tryghost/members-api@1.31.0
2021-09-07 16:51:25 +02:00
Fabien O'Carroll
8476e7cbd7 Added disconnectStripe method to handle cleaning up
refs https://github.com/TryGhost/Team/issues/1006

As part of the work to handle cleaning up webhooks when we disconnect
from Stripe, I'm moving the logic to clear out the Stripe related data
from the database into a disconnectStripe method. This then allows us to
start handling the cleanup of webhooks via the Stripe API.
2021-09-07 16:34:08 +02:00
Fabien O'Carroll
ae1f905766 Published new versions
- @tryghost/members-api@1.29.3
2021-09-06 13:10:42 +02:00
Fabien O'Carroll
b6e4eae272 Fixed comped members having a status of 'paid'
refs https://github.com/TryGhost/Team/issues/995

Since we reintroduced the comped status, we did not update the
subscription handling to correctly set members to a status of comped
when they were on a 'Complimentary' plan.
2021-09-06 13:06:30 +02:00
Fabien O'Carroll
dbae9f3233 Published new versions
- @tryghost/members-api@1.29.2
2021-09-06 12:50:25 +02:00
Fabien O'Carroll
66143dbb7c Updated options parameter to be optional
no-issue

Since updating the product repository to force transactions, the options
parameter was used in every call, meaning it wasn't optional any more,
which broke usage. This updates the parameter to have a default so that
existing usage still works.
2021-09-06 12:47:19 +02:00
Fabien O'Carroll
537c9cb02d Published new versions
- @tryghost/magic-link@1.0.11
 - @tryghost/members-api@1.29.1
 - @tryghost/members-csv@1.1.6
 - @tryghost/members-importer@0.3.2
 - @tryghost/members-ssr@1.0.12
2021-09-01 19:12:44 +02:00
Fabien O'Carroll
3b94ba7dce Fixed update method not using transaction for reads
no-issue

Since we run our product repository methods in transactions now we must
ensure that all database interations in the method use the transaction.
This adds the missing options to the reading of existing prices so that
they happen inside of the transaction.
2021-09-01 19:10:12 +02:00
Renovate Bot
b0133b3c2e Update dependency mocha to v9.1.1 2021-08-31 07:43:26 +00:00
Fabien O'Carroll
c782b3d2c9 Published new versions
- @tryghost/members-api@1.29.0
2021-08-26 20:07:08 +02:00
Fabien O'Carroll
82506e1599 Passed transaction to all model methods
refs https://github.com/TryGhost/Team/issues/982

These calls to the edit method were missing the transaction option from
the parent which meant that they ran outside of the transaction and
would cause the method to timeout.
2021-08-26 20:04:06 +02:00
Fabien O'Carroll
dd4d6aeae5 Wrapped product repo methods in transactions
refs https://github.com/TryGhost/Team/issues/982

This ensures that we will not commit any rows to the database if
something is to go wrong with a Stripe API request.
2021-08-26 20:03:16 +02:00
Fabien O'Carroll
dc79f04989 Published new versions
- @tryghost/members-api@1.28.0
2021-08-26 16:16:00 +02:00
Fabien O'Carroll
ec8dbf2890 Added products as default relation when fetching members
no-issue

As subscriptions are a default relation, and we now require products to
populate subscriptions for comped members, we need to include products
by default when reading members.
2021-08-26 16:10:13 +02:00
Fabien O'Carroll
0f4e97eae7 Updated getMemberIdentityData to use BREAD Service
refs https://github.com/TryGhost/Team/issues/986

The getMemberIdentityData is a relic of time past. Originally it was
used before we had anything like the member repository or bread
controller as a way for things inside of the Members ecosystem to get
access to member data.

This updates it to use the same interface as everything else for
fetching members so that we can rely on the shape of the data that we
consider a member.

This update will ensure that themes have access to the dummy
subscriptions created by the `read` method of the MemberBREADService.
2021-08-26 16:07:06 +02:00
Fabien O'Carroll
fa73786c92 Published new versions
- @tryghost/members-api@1.27.3
2021-08-26 15:54:13 +02:00
Fabien O'Carroll
d3b1283241 Removed old product when subscription is updated
refs https://github.com/TryGhost/Team/issues/979

This correctly handles updates to subscriptions so that if the product a
subscription is for has changed, we will remove the previous product, if
and only if there is not another subscription which gives access to it.
2021-08-26 15:53:38 +02:00
Fabien O'Carroll
16d67203cf Published new versions
- @tryghost/members-api@1.27.2
2021-08-26 13:03:41 +02:00
Fabien O'Carroll
83d4b5f834 Handled missing data in read method bread service
refs https://github.com/TryGhost/Team/issues/873

The `get` method of the member repository will return null when no
member is found - we must ensure that we don't attempt to call toJSON!

It is also possible for a member to not have any products, in which case
we should not attempt to iterate over them, and we can return early.
2021-08-26 12:58:39 +02:00
Fabien O'Carroll
58c06bce2e Published new versions
- @tryghost/members-api@1.27.1
2021-08-26 11:54:51 +02:00
Fabien O'Carroll
3a91687b08 Used current time for created_at for missing events
refs https://github.com/TryGhost/Team/issues/873

This is an unexpected state, but possible if the alpha version of tier
has been enabled previous to the events being added.
2021-08-26 11:52:53 +02:00
Fabien O'Carroll
40699893ba Published new versions
- @tryghost/members-api@1.27.0
2021-08-25 23:27:47 +02:00
Fabien O'Carroll
86f5879432 Added dummy subscriptions for comped members
refs https://github.com/TryGhost/Team/issues/873

This adds a dummy subscription for each product that a member has
without an associated stripe subscription. It allows clients to deal
with things like a created date for comped members.
2021-08-25 21:26:04 +02:00
Fabien O'Carroll
c17442cf4b Added memberService to members-api
no-issue

The idea of this service is to sit infront of the repository and handle
application logic which does not belong at the data layer. The exact
naming and structure is TBC but this gives us a place to start pulling
logic out of the controllers, without having to mash it all into the
repository.

Also important to note is that is does not return instances of bookshelf
models, but a JSON representation of the model, this allows us to not
leak internal implementation to consumers.
2021-08-25 21:25:19 +02:00
Fabien O'Carroll
a2120fc2d6 Published new versions
- @tryghost/members-api@1.26.0
2021-08-24 15:12:48 +02:00
Fabien O'Carroll
d55e828b34 Wired up MemberProductEvents to MemberRepository
refs https://github.com/TryGhost/Team/issues/873

This handles the creation of product events when a members access to
products is changed. This can happen on creation, update, and any
changes to stripe subscriptions.

We manually workout the difference between the current products and the
new products, and add the events accordingly.
2021-08-24 14:57:04 +02:00
Fabien O'Carroll
df753df87a Published new versions
- @tryghost/magic-link@1.0.10
 - @tryghost/members-api@1.25.2
 - @tryghost/members-csv@1.1.5
 - @tryghost/members-importer@0.3.1
 - @tryghost/members-ssr@1.0.11
2021-08-23 14:49:21 +02:00
Fabien O'Carroll
4b219626eb Fixed usage of bson-objectid
no-issue

Calling ObjectId doesn't return a string a but an ObjectId object.
Whilst this object is cast to a string via the toJSON and toString
methods, this is not enough for MySQL. Instead we should explicitly cast
this to a string ourselves and the application level.
2021-08-23 14:46:53 +02:00
Renovate Bot
2b15530e82 Update dependency mocha to v9.1.0 2021-08-23 02:56:38 +00:00
Naz
fe25f02d86 Published new versions
- @tryghost/magic-link@1.0.9
 - @tryghost/members-api@1.25.1
 - @tryghost/members-csv@1.1.4
 - @tryghost/members-importer@0.3.0
 - @tryghost/members-ssr@1.0.10
2021-08-20 17:31:40 +04:00
Naz
9cbe5efdf5 Removed checkEmailList flag check
refs https://github.com/TryGhost/Team/issues/906

- The feature is entering GA stage and the flag is no longer needed
2021-08-20 17:28:06 +04:00
Daniel Lockyer
6e4437c7e4 Added c8 test coverage
refs https://github.com/TryGhost/Team/issues/870

- using `c8` allows us to see test coverage for all packages in the repo
- this commit adds `c8` as a dev dependency and prepends the `mocha`
  command with `c8` so it runs on all tests
2021-08-20 10:28:07 +02:00
Naz
7ea1e28763 Published new versions
- @tryghost/members-importer@0.2.0
2021-08-18 16:11:05 +04:00
Naz
fd7f515055 Changed MembersCSVImporter constructor
refs https://github.com/TryGhost/Team/issues/958

- The import threshold has to become a dynamic number based on external parameters. Because of this it makes most sense to have it as an async function parameter
- There's a package API change for importThreshold constructor paramter becoming a fetchThreshold async funciton parameter
2021-08-18 16:09:33 +04:00
Fabien O'Carroll
df8136804d Published new versions
- @tryghost/members-api@1.25.0
2021-08-16 20:06:49 +02:00
Fabien 'egg' O'Carroll
4a8ec62317 Added bulkEdit method to MemberRepository
refs https://github.com/TryGhost/Team/issues/946

This adds the bulk edit method which handles bulk edit operations to members
to be used by the filtering feature. They have been combined into a single method
as that is how they are exposed to the API. This is definitely a candidate for a
refactor in the form of a service in front of the repository.
2021-08-16 19:05:48 +01:00
Fabien O'Carroll
be55c4e184 Published new versions
- @tryghost/members-api@1.24.1
2021-08-13 13:26:47 +02:00
Fabien O'Carroll
6540fd0cd0 Updated bulkDestroy method to handle model updates
refs https://github.com/TryGhost/Ghost/commit/1dd52075

- Fixes bulkDestroy being passed the context
- Fixes passing options.search to the model layer
- Updates return value since the changes in referenced commit
2021-08-13 13:23:01 +02:00
Fabien O'Carroll
7ee0df2ce6 Published new versions
- @tryghost/members-api@1.24.0
2021-08-12 13:58:53 +02:00
Fabien O'Carroll
6bb3407725 Added bulkDestroy method to Member Repository
no-issue

The logic for bulk destroy is currently incorrectly inside of the
members api controller in Ghost core. Moving it out to here allows us to
simplify the controller to rely on the service, rather than implement
the logic.
2021-08-12 13:57:45 +02:00
Fabien O'Carroll
daa3bb405d Published new versions
- @tryghost/members-api@1.23.3
2021-08-11 13:00:39 +02:00
Fabien O'Carroll
f4b7dfd08c Fixed status when subscriptions are canceled
refs https://github.com/TryGhost/Team/issues/959

Because we were using the pre-existing products to determine a members
status, instead of the products _after_ we have handled the updates to
subscriptions, members with a paid subscription which was later canceled
were changed to 'comped' rather than 'free'. This adds a final check to
set a member to 'free' if their new set of products is empty.
2021-08-11 11:59:32 +01:00
Naz
8fbd24626d Published new versions
- @tryghost/magic-link@1.0.8
 - @tryghost/members-api@1.23.2
 - @tryghost/members-csv@1.1.3
 - @tryghost/members-importer@0.1.2
 - @tryghost/members-ssr@1.0.9
2021-07-28 19:14:58 +04:00
Naz
96b3629280 Exposed originalImportSize from members importer
refs https://github.com/TryGhost/Team/issues/912

- The variable is needed as a datapoint in Ghost when sending stats about what the import size was used
2021-07-28 19:13:48 +04:00
Renovate Bot
e4109e38f3 Update dependency sinon to v11.1.2 2021-07-28 13:54:56 +00:00
Renovate Bot
102568a72a Update dependency mocha to v9.0.3 2021-07-27 04:36:33 +00:00
Naz
a4677deb29 Published new versions
- @tryghost/members-importer@0.1.1
2021-07-23 20:30:50 +04:00
Naz
a90d996f33 Added import threshold check to importer
refs https://github.com/TryGhost/Team/issues/912

- We need a way to check if the import threshold has been reached within the members importer. See more deets in refed issue
2021-07-23 20:29:19 +04:00
Rishabh
f90e36b816 Published new versions
- @tryghost/members-api@1.23.1
2021-07-22 12:53:03 +05:30
Rishabh
e28a19178d Added labels/products data to members identity
refs https://github.com/TryGhost/Team/issues/909
refs 3e13a6c562

`labels` and `products` data on member is needed for content gating post access for new segmented access
2021-07-22 12:52:02 +05:30
Rishabh
45ba046ad5 Published new versions
- @tryghost/members-api@1.23.0
2021-07-22 12:33:07 +05:30
Rishabh
3e13a6c562 Removed unused data from members identity data
refs https://github.com/TryGhost/Team/issues/909

The member identity data currently attaches several extra data points to member information which is not used/needed, and causes multiple DB queries on each page load when Portal requests for member via `/members/api/member` endpoint. This change removes all the unused data points on member - `labels`, `stripe_customer`, products`, `stripe_product` cutting DB queries in half.
2021-07-22 12:28:39 +05:30
Naz
7acc7bcb3d Published new versions
- @tryghost/members-importer@0.1.0
2021-07-21 19:27:35 +04:00
Naz
a99fec1a7b Fixed members importer tests from leaving files behind
no issue

- After each test run there were csv files lefover which polluted the workspace.
- Ideally the write file would be some kind of a smart mock, so we'd won't have to do synchronous file remoal after each test but that's for later improvement if it becomes problematic
2021-07-21 19:25:41 +04:00
Naz
9794fb8883 Fixed sinon dependency
no issue

- It was a duplicate from devDependencies
2021-07-21 18:05:00 +04:00
Naz
218a1334bd Added very basic unit test coverage to cover happy path import
refs https://github.com/TryGhost/Team/issues/916

- These tests are nowhere close to perfect of even good. They barely pass "good enough" watermark... it's a start for new tests to be added easier in the future once the features are developed around CSV improrter
2021-07-22 01:53:21 +12:00
Naz
633feccf8d Removed hello test
refs https://github.com/TryGhost/Team/issues/916
2021-07-22 01:53:21 +12:00
Naz
8b45f73079 Removed unused files
refs https://github.com/TryGhost/Team/issues/916
2021-07-22 01:53:21 +12:00
Naz
ef4b62e031 Fixed default package export
refs https://github.com/TryGhost/Team/issues/916
2021-07-22 01:53:21 +12:00
Naz
c87e12a906 Added sinon dependency for mocks in tests
refs https://github.com/TryGhost/Team/issues/916
2021-07-22 01:53:21 +12:00
Naz
25293b4cbc Added missing dependencies
refs https://github.com/TryGhost/Team/issues/916
2021-07-22 01:53:21 +12:00
Naz
a9981ea99e Initialized members-importer package
refs https://github.com/TryGhost/Team/issues/916

- Nothing interesting here. Scaffolding that slimer made
2021-07-22 01:53:21 +12:00
Naz
e9d186ced6 Refactored ghostMailer parameter
refs https://github.com/TryGhost/Team/issues/916

-  The constructor API should have as small of a surface as possible, there's no need to pass around whole ghostMailer instance
2021-07-22 01:53:21 +12:00
Naz
6aecf3e2a8 Refactored settingsCache parameter
refs https://github.com/TryGhost/Team/issues/916

-  The constructor API should have as small of a surface as possible, there's no need to pass around whole settingsCache instance
2021-07-22 01:53:21 +12:00
Naz
e04a8177d1 Refactored storagePath parameter
refs https://github.com/TryGhost/Team/issues/916

-  The refactor was done follow the DI Constructor pattern with single options Object parameter
- It didn't make sense to have a "config" object inside of options object containing just one property
2021-07-22 01:53:21 +12:00
Naz
1bf461f221 Refactored constructure signature to be a n object
refs https://github.com/TryGhost/Team/issues/916

-  The refactor was done follow the DI Constructor pattern with single options Object parameter
2021-07-22 01:53:21 +12:00
Naz
9c40c08cf3 Refactored url-uitls out of MembersCSVImporter
refs https://github.com/TryGhost/Team/issues/916

-  The refactor was done follow the DI Constructor pattern and prepare module for extraction
2021-07-22 01:53:21 +12:00
Naz
99560ca901 Refactored db dependency out of MembersCSVImporter
refs https://github.com/TryGhost/Team/issues/916

-  The refactor was done follow the DI Constructor pattern and prepare module for extraction
2021-07-22 01:53:21 +12:00
Naz
fdfd185835 Refactored jobs service out of MembersCSVImporter
refs https://github.com/TryGhost/Team/issues/916

-  The refactor was done follow the DI Constructor pattern and prepare module for extraction
2021-07-22 01:53:21 +12:00
Naz
6a8384cafb Refactored labs dependency out of MembersCSVImporter
refs https://github.com/TryGhost/Team/issues/916

-  The refactor was done follow the DI Constructor pattern and prepare module for extraction
2021-07-22 01:53:21 +12:00
Naz
c3b60a5628 Refactored Ghost mailer dependency out of MembersCSVImporter
refs https://github.com/TryGhost/Team/issues/916

-  The refactor was done follow the DI Constructor pattern and prepare module for extraction
2021-07-22 01:53:21 +12:00
Naz
8f169720d1 Removed dead code - batch-import module
refs https://github.com/TryGhost/Team/issues/916

- While investigating members importer related codebase this legacy module was spotted. It's not used anywhere and doesn't serve any particular purpose.
2021-07-22 01:53:21 +12:00
Fabien 'egg' O'Carroll
eca3ae1af3 Replaced usage of Error with @tryghost/errors (#13161)
refs 2f1123d6ca

Usage of the raw Error class has been deprecated in favour of our own
errors, which are more descriptive and have built in HTTP status codes.

This also updates the same errors to use @tryghost/tpl for the error
messages, which is the new pattern we are following in order for us to
deprecate the i18n module.
2021-07-22 01:53:21 +12:00
Hannah Wolfe
23748c92fb Moved labs utlity to shared
- This isn't really a "service" - it's a set of utilities for working with labs flags
- It's also required all over the place, and doesn't require anything that isn't shared
- Therefore, it should live in shared
2021-07-22 01:53:21 +12:00
Hannah Wolfe
e52fdbd737 Revert "Moved labs utlity to shared"
This reverts commit 693836322d96c5563671400f0346afa2e69276c4.
2021-07-22 01:53:21 +12:00
Hannah Wolfe
4550f68107 Moved labs utlity to shared
- This isn't really a "service" - it's a set of utilities for working with labs flags
- It's also required all over the place, and doesn't require anything that isn't shared
- Therefore, it should live in shared
2021-07-22 01:53:21 +12:00
Fabien O'Carroll
ee0cf47ce0 Added support for importing products column
refs https://github.com/TryGhost/Team/issues/765

This supercedes the `complimentary_plan` flag, as it is more precise
because it determines _which_ product(s) a member has access to. Because
of this, if the `products` column is present the `complimentary_plan`
column is not used.
2021-07-22 01:53:21 +12:00
Fabien O'Carroll
4141fd1e6a Linked comped members to default product for imports
refs https://github.com/TryGhost/Team/issues/765

As part of the multiple products feature, we're not longer using Stripe
subscriptions to denote Complimentary access, instead we're linking
members directly to products. Here we update the importer to follow
suit, so long as the flag is enabled.
2021-07-22 01:53:21 +12:00
Fabien O'Carroll
775b4a24f9 Moved MembersCSVImporter out of index.js file
no-issue

This cleans up the importer to match the standards of the rest of our
codebase.
2021-07-22 01:53:21 +12:00
Sam Lord
99bf0b29e2 Switch to @tryghost/debug, remove ghost-ignition
no issue
The only pieces of Ghost-Ignition used in Ghost were debug and
logging. Both of these modules have been superceded by the Framework
monorepo, and all usages of Ignition have now been removed, replaced
with @tryghost/debug and @tryghost/logging.
2021-07-22 01:53:21 +12:00
Sam Lord
ddeb980a9f Change to use @tryghost/logging
no issue

Logging is now controlled by a logginrc.js file in the root of the project - and now we can just import @tryghost/logging everywhere
2021-07-22 01:53:21 +12:00
Fabien O'Carroll
6a1d69c471 Made complimentary_plan & stripe_customer_id exclusive
no-issue

When importing Members it is possible to have both the
complimentary_plan and the stripe_customer_id columns set, this can
result in unusual outcomes, for example when importing a customer with a
zero-amount subscription, they would end up with two "comped"
subscriptions, and there would be two "comped" prices in the database.

As we are deprecating the use of "comped" in favour of creating a
subscription with a specific price, we're updating the import to prefer
`stripe_customer_id` column, only using the `complimentary_plan` column
when it is the only of the two columns passed.
2021-07-22 01:53:21 +12:00
Hannah Wolfe
a6d8f408b3 Moved i18n to shared
refs b51bba7b0e

- i18n is used everywhere but only requires shared or external packages, therefore it's a good candidate for living in shared
- this reduces invalid requires across frontend and server, and lets us use it everywhere until we come up with a better option
2021-07-22 01:53:21 +12:00
Hannah Wolfe
b8d64bfb28 Expanded requires of lib/common i18n and events
- Having these as destructured from the same package is hindering refactoring now
- Events should really only ever be used server-side
- i18n should be a shared module for now so it can be used everywhere until we figure out something better
- Having them seperate also allows us to lint them properly
2021-07-22 01:53:21 +12:00
Daniel Lockyer
119c013229 Updated bson-objectid calls to match API change
refs c873899e49

- as of `bson-objectid` v2.0.0, this library exports the function
  to generate an ObjectID directly, and then you need to use `.toHexString()`
  to get the 24 character hex string - 6696f27d82
- this commit removes all uses of `.generate()` and replaces with this
  change
2021-07-22 01:53:21 +12:00
Peter Zimon
ddedbd4225 Fixed member import email heading spacing 2021-07-22 01:53:21 +12:00