diff --git a/ghost/limit-service/lib/limit.js b/ghost/limit-service/lib/limit.js index f16e035e8a..c9afaf5b45 100644 --- a/ghost/limit-service/lib/limit.js +++ b/ghost/limit-service/lib/limit.js @@ -11,7 +11,7 @@ class Limit { * @param {String} options.name - name of the limit * @param {String} options.error - error message to use when limit is reached * @param {String} options.helpLink - URL to the resource explaining how the limit works - * @param {Object} options.db - instance of knex db connection that currentCountQuery can use to run state check through + * @param {Object} [options.db] - instance of knex db connection that currentCountQuery can use to run state check through * @param {Object} options.errors - instance of errors compatible with Ghost-Ignition's errors (https://github.com/TryGhost/Ignition#errors) */ constructor({name, error, helpLink, db, errors}) { @@ -99,6 +99,7 @@ class MaxLimit extends Limit { * * @param {Object} options * @param {Number} [options.max] - overrides configured default max value to perform checks against + * @param {Number} [options.addedCount] - number of items to add to the currentCount during the check */ async errorIfWouldGoOverLimit({max, addedCount = 1} = {}) { let currentCount = await this.currentCountQuery(this.db); @@ -130,6 +131,7 @@ class MaxPeriodicLimit extends Limit { * @param {String} options.name - name of the limit * @param {Object} options.config - limit configuration * @param {Number} options.config.maxPeriodic - maximum limit the limit would check against + * @param {String} options.config.error - error message to use when limit is reached * @param {Function} options.config.currentCountQuery - query checking the state that would be compared against the limit * @param {('month')} options.config.interval - an interval to take into account when checking the limit. Currently only supports 'month' value * @param {String} options.config.startDate - start date in ISO 8601 format (https://en.wikipedia.org/wiki/ISO_8601), used to calculate period intervals @@ -202,6 +204,7 @@ class MaxPeriodicLimit extends Limit { * * @param {Object} options * @param {Number} [options.max] - overrides configured default maxPeriodic value to perform checks against + * @param {Number} [options.addedCount] - number of items to add to the currentCount during the check */ async errorIfWouldGoOverLimit({max, addedCount = 1} = {}) { let currentCount = await this.currentCountQuery(this.db); @@ -233,6 +236,7 @@ class FlagLimit extends Limit { * @param {String} options.name - name of the limit * @param {Object} options.config - limit configuration * @param {Number} options.config.disabled - disabled/enabled flag for the limit + * @param {String} options.config.error - error message to use when limit is reached * @param {String} options.helpLink - URL to the resource explaining how the limit works * @param {Object} options.db - instance of knex db connection that currentCountQuery can use to run state check through * @param {Object} options.errors - instance of errors compatible with Ghost-Ignition's errors (https://github.com/TryGhost/Ignition#errors) @@ -275,6 +279,16 @@ class FlagLimit extends Limit { } class AllowlistLimit extends Limit { + /** + * + * @param {Object} options + * @param {String} options.name - name of the limit + * @param {Object} options.config - limit configuration + * @param {[String]} options.config.allowlist - allowlist values that would be compared against + * @param {String} options.config.error - error message to use when limit is reached + * @param {String} options.helpLink - URL to the resource explaining how the limit works + * @param {Object} options.errors - instance of errors compatible with Ghost-Ignition's errors (https://github.com/TryGhost/Ignition#errors) + */ constructor({name, config, helpLink, errors}) { super({name, error: config.error || '', helpLink, errors});