Skip to content

Commit d709737

Browse files
committed
Renamed limitActivityPub to limitSocialWeb
1 parent a4329bd commit d709737

File tree

3 files changed

+20
-20
lines changed

3 files changed

+20
-20
lines changed

packages/limit-service/README.md

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ const limitService = new LimitService();
2626

2727
// setup limit configuration
2828
// currently supported limit keys are: staff, members, customThemes, customIntegrations, uploads,
29-
// limitStripeConnect, limitAnalytics, and limitActivityPub
29+
// limitStripeConnect, limitAnalytics, and limitSocialWeb
3030
// all limit configs support custom "error" configuration that is a template string
3131
const limits = {
3232
// staff and member are "max" type of limits accepting "max" configuration
@@ -64,17 +64,17 @@ const limits = {
6464
uploads: {
6565
// max key is in bytes
6666
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
6868
error: 'Your plan supports uploads of max size up to {{max}}. Please upgrade to reenable uploading.'
6969
},
7070
limitStripeConnect: {},
7171
limitAnalytics: {},
72-
limitActivityPub: {}
72+
limitSocialWeb: {}
7373
};
7474

7575
// This information is needed for the limit service to work with "max periodic" limits
7676
// The interval value has to be 'month' as that's the only interval that was needed for
77-
// current usecase
77+
// current use case
7878
// The startDate has to be in ISO 8601 format (https://en.wikipedia.org/wiki/ISO_8601)
7979
const subscription = {
8080
interval: 'month',
@@ -112,7 +112,7 @@ if (limitService.isLimited('staff')) {
112112
await limitService.errorIfWouldGoOverLimit('staff', {max: 100});
113113
}
114114

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
116116
// for example it could be 1, 3, 5 or whatever amount of 'staff' is currently in the system
117117
const staffCount = await limitService.currentCountQuery('staff');
118118

@@ -158,18 +158,18 @@ db.transaction((transacting) => {
158158

159159
### Types of limits
160160
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.
165165

166166
### 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`.
168168

169169
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.
170170

171171
### 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:
173173

174174
```js
175175
const limitService = new LimitService();

packages/limit-service/lib/config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,5 +58,5 @@ module.exports = {
5858
},
5959
limitStripeConnect: {},
6060
limitAnalytics: {},
61-
limitActivityPub: {}
61+
limitSocialWeb: {}
6262
};

packages/limit-service/test/LimitService.test.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -133,22 +133,22 @@ describe('Limit Service', function () {
133133
members: {max: 100},
134134
emails: {disabled: true},
135135
limitStripeConnect: {disabled: true},
136-
limitActivityPub: {disabled: true}
136+
limitSocialWeb: {disabled: true}
137137
};
138138

139139
limitService.loadLimits({limits, errors});
140140

141-
limitService.limits.should.be.an.Object().with.properties(['staff', 'members', 'emails', 'limitStripeConnect', 'limitActivityPub']);
141+
limitService.limits.should.be.an.Object().with.properties(['staff', 'members', 'emails', 'limitStripeConnect', 'limitSocialWeb']);
142142
limitService.limits.staff.should.be.an.instanceOf(MaxLimit);
143143
limitService.limits.members.should.be.an.instanceOf(MaxLimit);
144144
limitService.limits.emails.should.be.an.instanceOf(FlagLimit);
145145
limitService.limits.limitStripeConnect.should.be.an.instanceOf(FlagLimit);
146-
limitService.limits.limitActivityPub.should.be.an.instanceOf(FlagLimit);
146+
limitService.limits.limitSocialWeb.should.be.an.instanceOf(FlagLimit);
147147
limitService.isLimited('staff').should.be.true();
148148
limitService.isLimited('members').should.be.true();
149149
limitService.isLimited('emails').should.be.true();
150150
limitService.isLimited('limitStripeConnect').should.be.true();
151-
limitService.isLimited('limitActivityPub').should.be.true();
151+
limitService.isLimited('limitSocialWeb').should.be.true();
152152
});
153153

154154
it('can load camel cased limits', function () {
@@ -266,7 +266,7 @@ describe('Limit Service', function () {
266266
limitStripeConnect: {
267267
disabled: true
268268
},
269-
limitActivityPub: {
269+
limitSocialWeb: {
270270
disabled: true
271271
}
272272
};
@@ -313,7 +313,7 @@ describe('Limit Service', function () {
313313
disabled: true
314314
// No currentCountQuery - will be considered over limit
315315
},
316-
limitActivityPub: {
316+
limitSocialWeb: {
317317
disabled: true
318318
// No currentCountQuery - will be considered over limit
319319
}
@@ -514,7 +514,7 @@ describe('Limit Service', function () {
514514
limitStripeConnect: {
515515
disabled: false // Not disabled, so won't be over limit
516516
},
517-
limitActivityPub: {
517+
limitSocialWeb: {
518518
disabled: false // Not disabled, so won't be over limit
519519
}
520520
};
@@ -537,7 +537,7 @@ describe('Limit Service', function () {
537537
// Should return false because no limits are exceeded
538538
(await limitService.checkIfAnyOverLimit(options)).should.be.false();
539539

540-
// We have 4 flag limits now: customIntegrations, limitAnalytics, limitStripeConnect, and limitActivityPub
540+
// We have 4 flag limits now: customIntegrations, limitAnalytics, limitStripeConnect, and limitSocialWeb
541541
sinon.assert.callCount(flagSpy, 4);
542542
sinon.assert.alwaysCalledWithExactly(flagSpy, options);
543543

0 commit comments

Comments
 (0)