Fixed optional syntax style for jsdoc

refs https://jsdoc.app/tags-param.html#optional-parameters-and-default-values

- using an equals sign in the type definition is part of the Google
  Closure syntax but we use the JSDoc syntax in all other places, and
  tsc detects the different syntax
- this commit standardizes the syntax ahead of enforcing a certain style
  down the line
This commit is contained in:
Daniel Lockyer 2022-10-16 14:43:35 +07:00
parent fdff8814b1
commit 54c143a1b4
No known key found for this signature in database
7 changed files with 37 additions and 30 deletions

View File

@ -22,8 +22,8 @@ module.exports = (snippet, frame) => {
/**
* @typedef {Object} SerializedSnippet
* @prop {string} id
* @prop {string=} name
* @prop {string=} mobiledoc
* @prop {string} [name]
* @prop {string} [mobiledoc]
* @prop {string} created_at
* @prop {string} updated_at
* @prop {string} created_by

View File

@ -216,15 +216,15 @@ function createSerializer(debugString, serialize) {
* @prop {string} id
* @prop {string} uuid
* @prop {string} email
* @prop {string=} name
* @prop {string=} note
* @prop {string} [name]
* @prop {string} [note]
* @prop {null|string} geolocation
* @prop {boolean} subscribed
* @prop {string} created_at
* @prop {string} updated_at
* @prop {string[]} labels
* @prop {SerializedMemberStripeSubscription[]} subscriptions
* @prop {SerializedMemberProduct[]=} products
* @prop {SerializedMemberProduct[]} [products]
* @prop {string} avatar_image
* @prop {boolean} comped
* @prop {number} email_count

View File

@ -73,6 +73,9 @@ function dropNullable(tableName, column, transaction = db.knex) {
});
}
/**
* @param {string}
*/
async function addColumn(tableName, column, transaction = db.knex, columnSpec) {
const addColumnBuilder = transaction.schema.table(tableName, function (table) {
addTableColumn(tableName, table, column, columnSpec);
@ -85,14 +88,16 @@ async function addColumn(tableName, column, transaction = db.knex, columnSpec) {
return;
}
let sql = addColumnBuilder.toSQL()[0].sql;
for (const sqlQuery of addColumnBuilder.toSQL()) {
let sql = sqlQuery.sql;
if (DatabaseInfo.isMySQL(transaction)) {
// Guard against an ending semicolon
sql = sql.replace(/;\s*$/, '') + ', algorithm=copy';
if (DatabaseInfo.isMySQL(transaction)) {
// Guard against an ending semicolon
sql = sql.replace(/;\s*$/, '') + ', algorithm=copy';
}
await transaction.raw(sql);
}
await transaction.raw(sql);
}
async function dropColumn(tableName, column, transaction = db.knex, columnSpec = {}) {
@ -101,25 +106,27 @@ async function dropColumn(tableName, column, transaction = db.knex, columnSpec =
await dropForeign({fromTable: tableName, fromColumn: column, toTable, toColumn, transaction});
}
const dropTableBuilder = transaction.schema.table(tableName, function (table) {
const dropColumnBuilder = transaction.schema.table(tableName, function (table) {
table.dropColumn(column);
});
// Use the default flow for SQLite because .toSQL() is tricky with SQLite when
// it does the table dance
if (DatabaseInfo.isSQLite(transaction)) {
await dropTableBuilder;
await dropColumnBuilder;
return;
}
let sql = dropTableBuilder.toSQL()[0].sql;
for (const sqlQuery of dropColumnBuilder.toSQL()) {
let sql = sqlQuery.sql;
if (DatabaseInfo.isMySQL(transaction)) {
// Guard against an ending semicolon
sql = sql.replace(/;\s*$/, '') + ', algorithm=copy';
if (DatabaseInfo.isMySQL(transaction)) {
// Guard against an ending semicolon
sql = sql.replace(/;\s*$/, '') + ', algorithm=copy';
}
await transaction.raw(sql);
}
await transaction.raw(sql);
}
/**

View File

@ -52,8 +52,8 @@ class MagicLink {
* @param {object} options
* @param {string} options.email - The email to send magic link to
* @param {TokenData} options.tokenData - The data for token
* @param {string=} [options.type='signin'] - The type to be passed to the url and content generator functions
* @param {string=} [options.referrer=null] - The referrer of the request, if exists
* @param {string} [options.type='signin'] - The type to be passed to the url and content generator functions
* @param {string} [options.referrer=null] - The referrer of the request, if exists
* @returns {Promise<{token: Token, info: SentMessageInfo}>}
*/
async sendMagicLink(options) {
@ -83,7 +83,7 @@ class MagicLink {
*
* @param {object} options
* @param {TokenData} options.tokenData - The data for token
* @param {string=} [options.type='signin'] - The type to be passed to the url and content generator functions. This type will also get stored in the token data.
* @param {string} [options.type='signin'] - The type to be passed to the url and content generator functions. This type will also get stored in the token data.
* @returns {Promise<URL>} - signin URL
*/
async getMagicLink(options) {

View File

@ -314,7 +314,7 @@ class ProductRepository {
* @param {string} data.welcome_page_url
* @param {BenefitInput[]} data.benefits
*
* @param {StripePriceInput[]=} data.stripe_prices
* @param {StripePriceInput[]} [data.stripe_prices]
* @param {StripePriceInput|null} data.monthly_price
* @param {StripePriceInput|null} data.yearly_price
*

View File

@ -139,7 +139,7 @@ module.exports = class StripeAPI {
* @param {string} id
* @param {object} options
* @param {boolean} options.active
* @param {string=} options.nickname
* @param {string} [options.nickname]
*
* @returns {Promise<IPrice>}
*/

View File

@ -97,7 +97,7 @@ module.exports = class WebhookManager {
/**
* @param {object} config
* @param {string=} config.webhookSecret An optional webhook secret for use with stripe-cli, passing this will ensure a webhook is not created in Stripe
* @param {string} [config.webhookSecret] An optional webhook secret for use with stripe-cli, passing this will ensure a webhook is not created in Stripe
* @param {string} config.webhookHandlerUrl The URL which the Webhook should hit
*
* @returns {Promise<void>}
@ -111,11 +111,11 @@ module.exports = class WebhookManager {
}
/**
* @param {string=} id
* @param {string=} secret
* @param {object=} opts
* @param {boolean} opts.forceCreate
* @param {boolean} opts.skipDelete
* @param {string} [id]
* @param {string} [secret]
* @param {object} [opts]
* @param {boolean} [opts.forceCreate]
* @param {boolean} [opts.skipDelete]
*
* @returns {Promise<Webhook>}
*/