Commit Graph

17 Commits

Author SHA1 Message Date
Naz
a61bf71a16 Added missing "should" imports
no issue
2021-10-26 15:50:43 +04:00
Naz
4172f993d4 Added custom formatter functionality to MaxLimit
refs https://linear.app/tryghost/issue/CORE-121/create-a-video-storage-adapter

 - Some variables (like file size) would be hard to comprehend with the default formatting. Instead allowed MaxLimit to be configured with a custom formatter
2021-10-26 15:49:26 +04:00
Naz
91a2e54484 Added ability to pass in "currentCount" for limited resource
refs https://linear.app/tryghost/issue/CORE-121/create-a-video-storage-adapter

- When checking limits for a nondb-resource type (like file size) there is no way to "currentCountQuery", so the value has to be passed in directly into the limit to evaluate against configured "max" limit
2021-10-26 15:42:10 +04:00
Naz
612cc2b513 Added addedCount to max and maxPeriodic limits
refs https://github.com/TryGhost/Team/issues/588

- The `addedCount` parameter in `errorIfWouldGoOverLimit` method allows to specify a custom resource count that is about to be added. Example usecase is when we'd want to send a 100 emails and current limit is 99, and none have been sent so far. With previous implementation the check would've passed because it only checked for single resource that would be added through "+1". Current implementation allows to specify the amount of recources to be added
2021-05-07 18:13:01 +04:00
Naz
9c738b13d1 Added added maxPeriodical checks
refs https://github.com/TryGhost/Team/issues/588

- This bit is putting together all the pieces for periodical limit checks. More tests are to come
2021-05-06 17:48:31 +04:00
Naz
1483a5c758 Fixed IncorrectUsageError initialization
no issue

- The error takes in an options object which should contain "message" property instead of a string
2021-05-06 15:50:36 +04:00
Naz
413549f9c0 Added "maxPeriodic" limit type
refs https://github.com/TryGhost/Team/issues/588

- This is a scaffolding for a new limit type which should allow to check limits based on periods (for example related to billing, subscription cycles)
2021-05-06 15:50:36 +04:00
Naz
a240582094 Fixed typos 2021-05-05 12:42:30 +04:00
Naz
47a6956175 Added test coverage for flag type of limits
refs https://github.com/TryGhost/Team/issues/588

- This is by no means an thorought test coverage but ensures the basics work and provides examples of how the limit should be used. To be continued :)
2021-05-03 12:02:01 +04:00
Thibaut Patel
8381346dce Added allowlist limit (#144)
issue https://github.com/TryGhost/Team/issues/510
2021-04-08 17:29:53 +02:00
Naz
a1962f38cd Removed ghost-ignition's errors dependency
refs https://github.com/TryGhost/Team/issues/597

- To be able to transpile the library for different runtimes (make it polymorphic) had to get rid of dependencies that were not compatible with ES  Modules
- By making errors an injectable constructor option it removes the depencency and allows to transpile the library for multiple targets
- The `errors` option is now a required parameter for `loadLimits` method. It errors if it's missing (error message copy inspired by content api error 69fcea0582/packages/content-api/lib/index.js (L21))
2021-04-05 16:17:57 +12:00
Naz
2d5aff434c Added optional max limit override to errorIfIsOverLimit
refs https://github.com/TryGhost/Team/issues/587
refs 73e7319406

- It's a symmetric change to the one introduce in the refenreced commit
- TLDR: allows to check if limit was reached if the user changes the limit
2021-04-01 18:27:29 +13:00
Naz
5dd3752f15 Added test coverage for is over limit check
refs https://github.com/TryGhost/Team/issues/587

- There was no test coverage for MaxLimit's errorIfIsOverLimit check. Added basic test to make sure upcoming modifications don't break existing functionality
2021-04-01 18:10:07 +13:00
Naz
3bcc4256f5 Grouped MaxLimit test cases into describe groups
refs https://github.com/TryGhost/Team/issues/587

- Clenup before adding even more test coverage
2021-04-01 18:03:32 +13:00
Naz
73e7319406 Added optional max limit override to errorIfWouldGoOverLimit
refs https://github.com/TryGhost/Team/issues/587

- The optional {max} passed as an option allows to override currently configured limit and do a theoretical new limit check. For example:  check if the max limit will be exceeded if the limit changes (user changes plans)
2021-04-01 17:59:52 +13:00
Naz
57e24b3677 Added incorrect 'max' usage error to MaxLimit
refs https://github.com/TryGhost/Team/issues/587

- When the 'max' configuration is missing the instance of the class breaks when used unexpectedly. Followed similar approach to currentCountQuery check  by failing fast in the constructor
2021-04-01 17:20:56 +13:00
Naz
299d3e3bd4 Added test coverage for max limit class
refs https://github.com/TryGhost/Team/issues/587

- Test were missing for class initialization and around how the limit currently works.
- Before extending it's behavior throught its valuable to cover current functionality to not accidentally break anything
2021-04-01 17:17:45 +13:00