@tryghost/limit-service 1.3.0 → 1.3.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.
Files changed (3) hide show
  1. package/README.md +11 -11
  2. package/lib/config.js +1 -1
  3. package/package.json +2 -2
package/README.md CHANGED
@@ -26,7 +26,7 @@ const limitService = new LimitService();
26
26
 
27
27
  // setup limit configuration
28
28
  // currently supported limit keys are: staff, members, customThemes, customIntegrations, uploads,
29
- // limitStripeConnect, limitAnalytics, and limitActivityPub
29
+ // limitStripeConnect, limitAnalytics, and limitSocialWeb
30
30
  // all limit configs support custom "error" configuration that is a template string
31
31
  const limits = {
32
32
  // staff and member are "max" type of limits accepting "max" configuration
@@ -64,17 +64,17 @@ const limits = {
64
64
  uploads: {
65
65
  // max key is in bytes
66
66
  max: 5000000,
67
- // formatting of the {{ max }} vairable is in MB, e.g: 5MB
67
+ // formatting of the {{ max }} variable is in MB, e.g: 5MB
68
68
  error: 'Your plan supports uploads of max size up to {{max}}. Please upgrade to reenable uploading.'
69
69
  },
70
70
  limitStripeConnect: {},
71
71
  limitAnalytics: {},
72
- limitActivityPub: {}
72
+ limitSocialWeb: {}
73
73
  };
74
74
 
75
75
  // This information is needed for the limit service to work with "max periodic" limits
76
76
  // The interval value has to be 'month' as that's the only interval that was needed for
77
- // current usecase
77
+ // current use case
78
78
  // The startDate has to be in ISO 8601 format (https://en.wikipedia.org/wiki/ISO_8601)
79
79
  const subscription = {
80
80
  interval: 'month',
@@ -112,7 +112,7 @@ if (limitService.isLimited('staff')) {
112
112
  await limitService.errorIfWouldGoOverLimit('staff', {max: 100});
113
113
  }
114
114
 
115
- // "max" types of limits have currentCountQuery method reguring a number that is currently in use for the limit
115
+ // "max" types of limits have currentCountQuery method requiring a number that is currently in use for the limit
116
116
  // for example it could be 1, 3, 5 or whatever amount of 'staff' is currently in the system
117
117
  const staffCount = await limitService.currentCountQuery('staff');
118
118
 
@@ -158,18 +158,18 @@ db.transaction((transacting) => {
158
158
 
159
159
  ### Types of limits
160
160
  At the moment there are four different types of limits that limit service allows to define. These types are:
161
- 1. `flag` - is an "on/off" switch for certain feature. Example usecase: "disable all emails". It's identified by a `disabled: true` property in the "limits" configuration. It is possible to overwrite the limit by providing a `currentCountQuery` for it. This is useful in cases where we introduce new limits to existing plans and customers have already been using the feature affected by the limit. By providing a `currentCountQuery` that detects if the feature is already in use, we won't disable it.
162
- 2. `max` - checks if the maximum amount of the resource has been used up.Example usecase: "disable creating a staff user when maximum of 5 has been reached". To configure this limit add `max: NUMBER` to the configuration. The limits that support max checks are: `members`, and `staff`
163
- 3. `maxPeriodic` - it's a variation of `max` type with a difference that the check is done over certain period of time. Example usecase: "disable sending emails when the sent emails count has acceded a limit for last billing period". To enable this limit define `maxPeriodic: NUMBER` in the limit configuration and provide a subscription configuration when initializing the limit service instance. The subscription object comes as a separate parameter and has to contain two properties: `startDate` and `interval`, where `startDate` is a date in ISO 8601 format and period is `'month'` (other values like `'year'` are not supported yet)
164
- 4. `allowList` - checks if provided value is defined in configured "allowlist". Example usecase: "disable theme activation if it is not an official theme". To configure this limit define ` allowlist: ['VALUE_1', 'VALUE_2', 'VALUE_N']` property in the "limits" parameter.
161
+ 1. `flag` - is an "on/off" switch for certain feature. Example use case: "disable all emails". It's identified by a `disabled: true` property in the "limits" configuration. It is possible to overwrite the limit by providing a `currentCountQuery` for it. This is useful in cases where we introduce new limits to existing plans and customers have already been using the feature affected by the limit. By providing a `currentCountQuery` that detects if the feature is already in use, we won't disable it.
162
+ 2. `max` - checks if the maximum amount of the resource has been used up.Example use case: "disable creating a staff user when maximum of 5 has been reached". To configure this limit add `max: NUMBER` to the configuration. The limits that support max checks are: `members`, and `staff`
163
+ 3. `maxPeriodic` - it's a variation of `max` type with a difference that the check is done over certain period of time. Example use case: "disable sending emails when the sent emails count has acceded a limit for last billing period". To enable this limit define `maxPeriodic: NUMBER` in the limit configuration and provide a subscription configuration when initializing the limit service instance. The subscription object comes as a separate parameter and has to contain two properties: `startDate` and `interval`, where `startDate` is a date in ISO 8601 format and period is `'month'` (other values like `'year'` are not supported yet)
164
+ 4. `allowList` - checks if provided value is defined in configured "allowlist". Example use case: "disable theme activation if it is not an official theme". To configure this limit define ` allowlist: ['VALUE_1', 'VALUE_2', 'VALUE_N']` property in the "limits" parameter.
165
165
 
166
166
  ### Supported limits
167
- There's a limited amount of limits that are supported by limit service. The are defined by "key" property name in the "config" module. List of currently supported limit names: `members`, `staff`, `customIntegrations`, `emails`, `customThemes`, `uploads`, `limitStripeConnect`, `limitAnalytics`, and `limitActivityPub`.
167
+ There's a limited amount of limits that are supported by limit service. The are defined by "key" property name in the "config" module. List of currently supported limit names: `members`, `staff`, `customIntegrations`, `emails`, `customThemes`, `uploads`, `limitStripeConnect`, `limitAnalytics`, and `limitSocialWeb`.
168
168
 
169
169
  All limits can act as `flag` or `allowList` types. Only certain (`members`, `staff`) can have a `max` limit. Only `emails` currently supports the `maxPeriodic` type of limit.
170
170
 
171
171
  ### Frontend usage
172
- In case the limit check is run without direct access to the database you can override `currentCountQuery` functions for each "max" or "maxPeriodic" type of limit. An example usecase would be a frontend client running in a browser. A browser client can check the limit data through HTTP request and then provide that data to the limit service. Example code to do exactly that:
172
+ In case the limit check is run without direct access to the database you can override `currentCountQuery` functions for each "max" or "maxPeriodic" type of limit. An example use case would be a frontend client running in a browser. A browser client can check the limit data through HTTP request and then provide that data to the limit service. Example code to do exactly that:
173
173
 
174
174
  ```js
175
175
  const limitService = new LimitService();
package/lib/config.js CHANGED
@@ -58,5 +58,5 @@ module.exports = {
58
58
  },
59
59
  limitStripeConnect: {},
60
60
  limitAnalytics: {},
61
- limitActivityPub: {}
61
+ limitSocialWeb: {}
62
62
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tryghost/limit-service",
3
- "version": "1.3.0",
3
+ "version": "1.3.1",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/TryGhost/SDK.git",
@@ -34,5 +34,5 @@
34
34
  "lodash": "^4.17.21",
35
35
  "luxon": "^1.26.0"
36
36
  },
37
- "gitHead": "a4329bd0bf75c10a862bb1c8761b45a6b08c5c2a"
37
+ "gitHead": "01a3b9421038ee84b0e0198a7d83740673eade12"
38
38
  }