diff --git a/ghost/offers/lib/application/OfferRepository.js b/ghost/offers/lib/application/OfferRepository.js index f8a99d7618..1a2a70cd3a 100644 --- a/ghost/offers/lib/application/OfferRepository.js +++ b/ghost/offers/lib/application/OfferRepository.js @@ -4,10 +4,16 @@ const Offer = require('../domain/models/Offer'); const OfferStatus = require('../domain/models/OfferStatus'); /** - * @typedef {object} OfferRepositoryOptions + * @typedef {object} BaseOptions * @prop {import('knex').Transaction} transacting */ +/** + * @extends BaseOptions + * @typedef {object} ListOptions + * @prop {string} filter + */ + /** * @param {any} json * @returns {Offer.OfferCreateProps} @@ -57,7 +63,7 @@ class OfferRepository { /** * @param {string} name - * @param {OfferRepositoryOptions} [options] + * @param {BaseOptions} [options] * @returns {Promise} */ async existsByName(name, options) { @@ -70,7 +76,7 @@ class OfferRepository { /** * @param {string} code - * @param {OfferRepositoryOptions} [options] + * @param {BaseOptions} [options] * @returns {Promise} */ async existsByCode(code, options) { @@ -83,7 +89,7 @@ class OfferRepository { /** * @param {string} id - * @param {OfferRepositoryOptions} [options] + * @param {BaseOptions} [options] * @returns {Promise} */ async getById(id, options) { @@ -98,7 +104,7 @@ class OfferRepository { } /** - * @param {OfferRepositoryOptions} [options] + * @param {ListOptions} options * @returns {Promise} */ async getAll(options) { @@ -111,7 +117,7 @@ class OfferRepository { /** * @param {Offer} offer - * @param {OfferRepositoryOptions} [options] + * @param {BaseOptions} [options] * @returns {Promise} */ async save(offer, options) { diff --git a/ghost/offers/lib/application/OffersAPI.js b/ghost/offers/lib/application/OffersAPI.js index 652e271e9d..8cd6a04ad8 100644 --- a/ghost/offers/lib/application/OffersAPI.js +++ b/ghost/offers/lib/application/OffersAPI.js @@ -99,13 +99,15 @@ class OffersAPI { } /** + * @param {object} options + * @param {string} options.filter * @returns {Promise} */ - async listOffers() { + async listOffers(options) { return await this.repository.createTransaction(async (transaction) => { - const options = {transacting: transaction}; + const opts = {transacting: transaction, filter: options.filter}; - const offers = await this.repository.getAll(options); + const offers = await this.repository.getAll(opts); return offers.map(OfferMapper.toDTO); });