Improved types for Offer

no-issue

This splits out the types of the Offers properties from the types of the
expected values to be passed to create.
This commit is contained in:
Fabien O'Carroll 2021-10-07 17:34:10 +02:00
parent 2b58ecd82e
commit 170591a113
2 changed files with 17 additions and 1 deletions

View File

@ -9,7 +9,7 @@ const Offer = require('./domain/models/Offer');
/**
* @param {any} json
* @returns {Offer.OfferProps}
* @returns {Offer.OfferCreateProps}
*/
function toDomain(json) {
return {

View File

@ -27,6 +27,22 @@ const OfferCurrency = require('./OfferCurrency');
* @prop {OfferTier} tier
*/
/**
* @typedef {object} OfferCreateProps
* @prop {string} id
* @prop {string} name
* @prop {string} code
* @prop {string} display_title
* @prop {string} display_description
* @prop {string} cadence
* @prop {string} type
* @prop {number} amount
* @prop {string} duration
* @prop {string} currency
* @prop {string} [stripe_coupon_id]
* @prop {TierProps|OfferTier} tier
*/
/**
* @typedef {object} UniqueChecker
* @prop {(code: OfferCode) => Promise<boolean>} isUniqueCode