Mailspring/spec
Evan Morikawa e638e94084 feat(usage): Add a FeatureUsageStore and move Identity to the DB
Summary:
This is a WIP

Depends on D3799 on billing.nylas.com

This adds a `FeatureUsageStore` which determines whether a feature can be
used or not. It also allows us to record "using" a feature.

Feature Usage is ultimately backed by the Nylas Identity and cached
locally in the Identity object. Since feature usage is attached to the
Nylas Identity, we move the whole Identity object (except for the ID) to
the database.

This includes a migration (with tests!) to move the Nylas Identity from
the config into the Database. We still, however, need the Nylas ID to stay
in the config so it can be synchronously accessed by the /browser process
on bootup when determining what windows to show. It's also convenient to
know what the Nylas ID is by looking at the config. There's logic (with
tests!) to make sure these stay in sync. If you delete the Nylas ID from
the config, it'll be the same as logging you out.

The schema for the feature usage can be found in more detail on D3799. By
the time it reaches Nylas Mail, the Nylas ID object has a `feature_usage`
attribute that has each feature (keyed by the feature name) and
information about the plans attached to it. The schema Nylas Mail sees
looks like:

```
"feature_usage": {
   "snooze": {
     quota: 10,
     peroid: 'monthly',
     used_in_period: 8,
     feature_limit_name: 'Snooze Group A',
   },
}
```

See D3799 for more info about how these are generated.

One final change that's in here is how Stores are loaded. Most of our
core stores are loaded at require time, but now things like the
IdentityStore need to do asynchronous things on activation. In reality
most of our stores do this and it's a miracle it hasn't caused more
problems! Now when stores activate we optionally look for an `activate`
method and `await` for it. This was necessary so downstream classes (like
the Onboarding Store), see a fully initialized IdentityStore by the time
it's time to use them

Test Plan: New tests!

Reviewers: khamidou, juan, halla

Reviewed By: juan

Differential Revision: https://phab.nylas.com/D3808
2017-02-03 15:31:31 -08:00
..
components fix(spec): add support for async specs and disable misbehaving ones 2016-12-15 13:02:00 -05:00
fixtures 🎨(rename): Update Nylas N1 to Nylas Mail 2017-01-12 12:05:44 -08:00
models 🎨(rename): Update Nylas N1 to Nylas Mail 2017-01-12 12:05:44 -08:00
n1-spec-runner feat(specs) Clean up local-sync database after each spec 2017-02-02 14:52:22 -08:00
registries refactor(registry): move all registries into src/registries 2016-11-14 14:01:00 -08:00
services fix(rendering): Fix quote stripping of many plaintext emails 2016-12-15 18:40:34 -08:00
stores feat(usage): Add a FeatureUsageStore and move Identity to the DB 2017-02-03 15:31:31 -08:00
tasks fix(tasks) ChangeMailTask should depend on EnsureMessagesInSentFolder 2017-01-27 14:02:50 -08:00
themes rm(grim): We’re not using Grim for deprecations 2016-10-25 11:36:20 -07:00
utils fix(specs) Fix date-utils specs 2016-11-07 12:15:47 -08:00
action-bridge-spec.coffee perf(sync): don't send message bodies across IPC & limit global IPC 2017-01-16 10:28:49 -08:00
async-test-spec.es6 fix(spec): add support for async specs and disable misbehaving ones 2016-12-15 13:02:00 -05:00
auto-update-manager-spec.coffee feat(usage): Add a FeatureUsageStore and move Identity to the DB 2017-02-03 15:31:31 -08:00
buffered-process-spec.coffee refactor(spec) move spec-nylas to spec 2015-10-01 21:39:44 -07:00
database-object-registry-spec.es6 refactor(registry): move all registries into src/registries 2016-11-14 14:01:00 -08:00
default-client-helper-spec.coffee feat(win32): Allow N1 to become the system-wide mailto: handler 2016-10-12 16:05:36 -07:00
list-selection-spec.coffee fix(specs): Add regression test for list-selection 2016-11-02 11:46:28 -07:00
mail-rules-processor-spec.coffee fix(spec): add support for async specs and disable misbehaving ones 2016-12-15 13:02:00 -05:00
mailbox-perspective-spec.es6 lint(*): Bump to ESLint 3.8 2016-10-17 18:07:35 -07:00
menu-manager-spec.coffee es6(*): Misc src to ES2016 2016-10-27 12:08:59 -07:00
module-cache-spec.coffee fix(specs): Update specs following 0.29.2 > 0.34.3 move 2015-11-17 17:40:06 -08:00
nylas-api-spec.coffee fix(spec): add support for async specs and disable misbehaving ones 2016-12-15 13:02:00 -05:00
nylas-env-spec.es6 fix(spec): add support for async specs and disable misbehaving ones 2016-12-15 13:02:00 -05:00
nylas-protocol-handler-spec.es6 fix(specs) convert nylas-protocol-handler-spec to ES6 (#2886) 2016-10-12 11:38:30 -07:00
nylas-test-utils.coffee cson(cleanup): Remove imports, only used for config.cson now 2016-04-24 20:33:34 -05:00
package-manager-spec.coffee fix(spec): add support for async specs and disable misbehaving ones 2016-12-15 13:02:00 -05:00
package-spec.coffee cleanup(specs): Remove space-pen. Goodbye, jQuery! 2016-04-26 13:14:07 -07:00
spellchecker-spec.es6 bump(spellcheck) upgrade to 1.0.0 2017-01-25 15:26:38 -05:00
undo-stack-spec.es6 lint(*): Bump to ESLint 3.8 2016-10-17 18:07:35 -07:00