diff --git a/data/config.defaultValues.d.ts b/data/config.defaultValues.d.ts index 8e46190..5bf2278 100644 --- a/data/config.defaultValues.d.ts +++ b/data/config.defaultValues.d.ts @@ -9,9 +9,10 @@ export declare const configDefaultValues: { 'modules.inventoryScanner.reports.w311': ConfigScheduledFtpReport; 'modules.inventoryScanner.reports.w604': ConfigScheduledFtpReport; 'modules.worktechUpdate.isEnabled': boolean; - 'modules.resourceItem.itemClass': string; - 'modules.resourceItem.itemType': string; - 'modules.resourceItem.unit': string; + 'modules.worktechUpdate.runOnStartup': boolean; + 'modules.worktechUpdate.resourceItem.itemClass': string; + 'modules.worktechUpdate.resourceItem.itemType': string; + 'modules.worktechUpdate.resourceItem.unit': string; 'modules.worktechUpdate.reports.w217': ConfigScheduledFtpReport; 'modules.worktechUpdate.reports.w223': ConfigScheduledFtpReport; }; diff --git a/data/config.defaultValues.js b/data/config.defaultValues.js index 9590b7c..79fa184 100644 --- a/data/config.defaultValues.js +++ b/data/config.defaultValues.js @@ -12,9 +12,10 @@ export const configDefaultValues = { * Worktech Update */ 'modules.worktechUpdate.isEnabled': false, - 'modules.resourceItem.itemClass': 'FASTER', - 'modules.resourceItem.itemType': 'FASTER', - 'modules.resourceItem.unit': 'EA', + 'modules.worktechUpdate.runOnStartup': true, + 'modules.worktechUpdate.resourceItem.itemClass': 'FASTER', + 'modules.worktechUpdate.resourceItem.itemType': 'FASTER', + 'modules.worktechUpdate.resourceItem.unit': 'EA', 'modules.worktechUpdate.reports.w217': undefined, 'modules.worktechUpdate.reports.w223': undefined }; diff --git a/data/config.defaultValues.ts b/data/config.defaultValues.ts index a201567..e8e70b8 100644 --- a/data/config.defaultValues.ts +++ b/data/config.defaultValues.ts @@ -31,10 +31,11 @@ export const configDefaultValues = { */ 'modules.worktechUpdate.isEnabled': false, + 'modules.worktechUpdate.runOnStartup': true, - 'modules.resourceItem.itemClass': 'FASTER', - 'modules.resourceItem.itemType': 'FASTER', - 'modules.resourceItem.unit': 'EA', + 'modules.worktechUpdate.resourceItem.itemClass': 'FASTER', + 'modules.worktechUpdate.resourceItem.itemType': 'FASTER', + 'modules.worktechUpdate.resourceItem.unit': 'EA', 'modules.worktechUpdate.reports.w217': undefined as unknown as ConfigScheduledFtpReport, diff --git a/modules/worktechUpdate/helpers/moduleHelpers.d.ts b/modules/worktechUpdate/helpers/moduleHelpers.d.ts new file mode 100644 index 0000000..b238e9d --- /dev/null +++ b/modules/worktechUpdate/helpers/moduleHelpers.d.ts @@ -0,0 +1 @@ +export declare const moduleName = "Worktech Update Module"; diff --git a/modules/worktechUpdate/helpers/moduleHelpers.js b/modules/worktechUpdate/helpers/moduleHelpers.js new file mode 100644 index 0000000..ddbcab6 --- /dev/null +++ b/modules/worktechUpdate/helpers/moduleHelpers.js @@ -0,0 +1 @@ +export const moduleName = 'Worktech Update Module'; diff --git a/modules/worktechUpdate/helpers/moduleHelpers.ts b/modules/worktechUpdate/helpers/moduleHelpers.ts new file mode 100644 index 0000000..8ed6ef4 --- /dev/null +++ b/modules/worktechUpdate/helpers/moduleHelpers.ts @@ -0,0 +1 @@ +export const moduleName = 'Worktech Update Module' \ No newline at end of file diff --git a/modules/worktechUpdate/helpers/worktechHelpers.js b/modules/worktechUpdate/helpers/worktechHelpers.js index a42b591..d5e6005 100644 --- a/modules/worktechUpdate/helpers/worktechHelpers.js +++ b/modules/worktechUpdate/helpers/worktechHelpers.js @@ -13,11 +13,11 @@ export async function getOrCreateStoreroomResourceItem(storeroomData) { itemId: storeroomItemId, externalItemId: storeroomData.storeroom, itemDescription: storeroomData.storeroomDescription, - itemClass: getConfigProperty('modules.resourceItem.itemClass'), - itemType: getConfigProperty('modules.resourceItem.itemType'), + itemClass: getConfigProperty('modules.worktechUpdate.resourceItem.itemClass'), + itemType: getConfigProperty('modules.worktechUpdate.resourceItem.itemType'), stock: 0, quantityOnHand: 0, - unit: getConfigProperty('modules.resourceItem.unit'), + unit: getConfigProperty('modules.worktechUpdate.resourceItem.unit'), unitCost: 0, }); worktechStoreroomResourceItem = (await worktech.getItemByItemId(storeroomItemId)); diff --git a/modules/worktechUpdate/helpers/worktechHelpers.ts b/modules/worktechUpdate/helpers/worktechHelpers.ts index 84cd9b6..d5a9d66 100644 --- a/modules/worktechUpdate/helpers/worktechHelpers.ts +++ b/modules/worktechUpdate/helpers/worktechHelpers.ts @@ -31,11 +31,11 @@ export async function getOrCreateStoreroomResourceItem( itemId: storeroomItemId, externalItemId: storeroomData.storeroom, itemDescription: storeroomData.storeroomDescription, - itemClass: getConfigProperty('modules.resourceItem.itemClass'), - itemType: getConfigProperty('modules.resourceItem.itemType'), + itemClass: getConfigProperty('modules.worktechUpdate.resourceItem.itemClass'), + itemType: getConfigProperty('modules.worktechUpdate.resourceItem.itemType'), stock: 0, quantityOnHand: 0, - unit: getConfigProperty('modules.resourceItem.unit'), + unit: getConfigProperty('modules.worktechUpdate.resourceItem.unit'), unitCost: 0, }) diff --git a/modules/worktechUpdate/initializeWorktechUpdateModule.js b/modules/worktechUpdate/initializeWorktechUpdateModule.js index f8684b4..10da74a 100644 --- a/modules/worktechUpdate/initializeWorktechUpdateModule.js +++ b/modules/worktechUpdate/initializeWorktechUpdateModule.js @@ -1,33 +1,42 @@ +import { dateToString, dateToTimePeriodString } from '@cityssm/utils-datetime'; +import camelCase from 'camelcase'; import Debug from 'debug'; import exitHook from 'exit-hook'; import schedule from 'node-schedule'; import { getConfigProperty } from '../../helpers/functions.config.js'; import { initializeWorktechUpdateDatabase } from './database/databaseHelpers.js'; -import directChargeHelperTask, { taskName as directChangeHelperTaskName } from './tasks/directChargeHelperTask.js'; -import inventoryTransactionsTask from './tasks/inventoryTransactionsTask.js'; -const debug = Debug('faster-web-helper:worktechUpdate'); +import { moduleName } from './helpers/moduleHelpers.js'; +import directChargeHelperTask, { taskName as directChargeHelperTaskName } from './tasks/directChargeHelperTask.js'; +import inventoryTransactionsTask, { taskName as inventoryTransactionsTaskName } from './tasks/inventoryTransactionsTask.js'; +const debug = Debug(`faster-web-helper:${camelCase(moduleName)}`); const directChargeTransactionsConfig = getConfigProperty('modules.worktechUpdate.reports.w217'); const inventoryTransactionsConfig = getConfigProperty('modules.worktechUpdate.reports.w223'); export default async function initializeWorktechUpdateModule() { - debug('Initializing "Worktech Update Module"...'); + debug(`Initializing "${moduleName}"...`); /* * Ensure the local database is available. */ initializeWorktechUpdateDatabase(); /* - * Direct Charge Helper Task + * Run on startup */ - debug('Running "Direct Charge Helper Task" on startup...'); - await directChargeHelperTask(); - debug('Scheduling "Direct Charge Helper Task"...'); - const directChargeHelperJob = schedule.scheduleJob(directChangeHelperTaskName, directChargeTransactionsConfig.schedule, directChargeHelperTask); + if (getConfigProperty('modules.worktechUpdate.runOnStartup')) { + debug(`Running "${directChargeHelperTaskName}" on startup...`); + await directChargeHelperTask(); + debug(`Running "${inventoryTransactionsTaskName}" on startup...`); + await inventoryTransactionsTask(); + } /* - * Inventory Transactions Task + * Schedule jobs */ - debug('Running "Inventory Transactions Task" on startup...'); - await inventoryTransactionsTask(); - debug('Scheduling "Inventory Transactions Task"...'); - const inventoryTransactionsJob = schedule.scheduleJob('inventoryTransactionsTask', inventoryTransactionsConfig.schedule, inventoryTransactionsTask); + debug(`Scheduling "${directChargeHelperTaskName}"...`); + const directChargeHelperJob = schedule.scheduleJob(directChargeHelperTaskName, directChargeTransactionsConfig.schedule, directChargeHelperTask); + const directChargeHelperFirstRunDate = new Date(directChargeHelperJob.nextInvocation().getTime()); + debug(`Scheduled to run "${directChargeHelperTaskName}" on ${dateToString(directChargeHelperFirstRunDate)} at ${dateToTimePeriodString(directChargeHelperFirstRunDate)}`); + debug(`Scheduling "${inventoryTransactionsTaskName}"...`); + const inventoryTransactionsJob = schedule.scheduleJob(inventoryTransactionsTaskName, inventoryTransactionsConfig.schedule, inventoryTransactionsTask); + const inventoryTransactionsFirstRunDate = new Date(inventoryTransactionsJob.nextInvocation().getTime()); + debug(`Scheduled to run "${inventoryTransactionsTaskName}" on ${dateToString(inventoryTransactionsFirstRunDate)} at ${dateToTimePeriodString(inventoryTransactionsFirstRunDate)}`); /* * Set up exit hook */ @@ -36,5 +45,5 @@ export default async function initializeWorktechUpdateModule() { directChargeHelperJob.cancel(); inventoryTransactionsJob.cancel(); }); - debug('"Worktech Update Module" initialized.'); + debug(`"${moduleName}" initialized.`); } diff --git a/modules/worktechUpdate/initializeWorktechUpdateModule.ts b/modules/worktechUpdate/initializeWorktechUpdateModule.ts index 64ff132..a6f271a 100644 --- a/modules/worktechUpdate/initializeWorktechUpdateModule.ts +++ b/modules/worktechUpdate/initializeWorktechUpdateModule.ts @@ -1,3 +1,5 @@ +import { dateToString, dateToTimePeriodString } from '@cityssm/utils-datetime' +import camelCase from 'camelcase' import Debug from 'debug' import exitHook from 'exit-hook' import schedule from 'node-schedule' @@ -5,12 +7,15 @@ import schedule from 'node-schedule' import { getConfigProperty } from '../../helpers/functions.config.js' import { initializeWorktechUpdateDatabase } from './database/databaseHelpers.js' +import { moduleName } from './helpers/moduleHelpers.js' import directChargeHelperTask, { - taskName as directChangeHelperTaskName + taskName as directChargeHelperTaskName } from './tasks/directChargeHelperTask.js' -import inventoryTransactionsTask from './tasks/inventoryTransactionsTask.js' +import inventoryTransactionsTask, { + taskName as inventoryTransactionsTaskName +} from './tasks/inventoryTransactionsTask.js' -const debug = Debug('faster-web-helper:worktechUpdate') +const debug = Debug(`faster-web-helper:${camelCase(moduleName)}`) const directChargeTransactionsConfig = getConfigProperty( 'modules.worktechUpdate.reports.w217' @@ -21,7 +26,7 @@ const inventoryTransactionsConfig = getConfigProperty( ) export default async function initializeWorktechUpdateModule(): Promise { - debug('Initializing "Worktech Update Module"...') + debug(`Initializing "${moduleName}"...`) /* * Ensure the local database is available. @@ -30,33 +35,51 @@ export default async function initializeWorktechUpdateModule(): Promise { initializeWorktechUpdateDatabase() /* - * Direct Charge Helper Task + * Run on startup */ - debug('Running "Direct Charge Helper Task" on startup...') - await directChargeHelperTask() + if (getConfigProperty('modules.worktechUpdate.runOnStartup')) { + debug(`Running "${directChargeHelperTaskName}" on startup...`) + await directChargeHelperTask() - debug('Scheduling "Direct Charge Helper Task"...') + debug(`Running "${inventoryTransactionsTaskName}" on startup...`) + await inventoryTransactionsTask() + } + + /* + * Schedule jobs + */ + + debug(`Scheduling "${directChargeHelperTaskName}"...`) const directChargeHelperJob = schedule.scheduleJob( - directChangeHelperTaskName, + directChargeHelperTaskName, directChargeTransactionsConfig.schedule, directChargeHelperTask ) - /* - * Inventory Transactions Task - */ + const directChargeHelperFirstRunDate = new Date( + directChargeHelperJob.nextInvocation().getTime() + ) - debug('Running "Inventory Transactions Task" on startup...') - await inventoryTransactionsTask() + debug( + `Scheduled to run "${directChargeHelperTaskName}" on ${dateToString(directChargeHelperFirstRunDate)} at ${dateToTimePeriodString(directChargeHelperFirstRunDate)}` + ) - debug('Scheduling "Inventory Transactions Task"...') + debug(`Scheduling "${inventoryTransactionsTaskName}"...`) const inventoryTransactionsJob = schedule.scheduleJob( - 'inventoryTransactionsTask', + inventoryTransactionsTaskName, inventoryTransactionsConfig.schedule, inventoryTransactionsTask ) + const inventoryTransactionsFirstRunDate = new Date( + inventoryTransactionsJob.nextInvocation().getTime() + ) + + debug( + `Scheduled to run "${inventoryTransactionsTaskName}" on ${dateToString(inventoryTransactionsFirstRunDate)} at ${dateToTimePeriodString(inventoryTransactionsFirstRunDate)}` + ) + /* * Set up exit hook */ @@ -67,5 +90,5 @@ export default async function initializeWorktechUpdateModule(): Promise { inventoryTransactionsJob.cancel() }) - debug('"Worktech Update Module" initialized.') + debug(`"${moduleName}" initialized.`) } diff --git a/modules/worktechUpdate/tasks/directChargeHelperTask.d.ts b/modules/worktechUpdate/tasks/directChargeHelperTask.d.ts index ea8d2eb..22337aa 100644 --- a/modules/worktechUpdate/tasks/directChargeHelperTask.d.ts +++ b/modules/worktechUpdate/tasks/directChargeHelperTask.d.ts @@ -1,4 +1,4 @@ -export declare const taskName = "directChangeHelperTask"; +export declare const taskName = "Direct Change Helper Task"; /** * - Maintains mappings between Faster document numbers and Worktech work order numbers. * - Tracks "Return to Vendor" transactions. diff --git a/modules/worktechUpdate/tasks/directChargeHelperTask.js b/modules/worktechUpdate/tasks/directChargeHelperTask.js index b6c9564..eb7ef4c 100644 --- a/modules/worktechUpdate/tasks/directChargeHelperTask.js +++ b/modules/worktechUpdate/tasks/directChargeHelperTask.js @@ -2,6 +2,7 @@ import fs from 'node:fs/promises'; import { parseW217ExcelReport } from '@cityssm/faster-api/xlsxReports.js'; import { dateStringToInteger, timeStringToInteger } from '@cityssm/utils-datetime'; import { WorkTechAPI } from '@cityssm/worktech-api'; +import camelCase from 'camelcase'; import Debug from 'debug'; import { getConfigProperty } from '../../../helpers/functions.config.js'; import { downloadFilesToTemp } from '../../../helpers/functions.sftp.js'; @@ -10,8 +11,9 @@ import addWorkOrderNumberMapping from '../database/addWorkOrderNumberMapping.js' import getReturnToVendorRecord from '../database/getReturnToVendorRecord.js'; import getWorkOrderNumberMapping from '../database/getWorkOrderNumberMapping.js'; import updateWorkOrderNumberMapping from '../database/updateWorkOrderNumberMapping.js'; -export const taskName = 'directChangeHelperTask'; -const debug = Debug(`faster-web-helper:worktechUpdate:${taskName}`); +import { moduleName } from '../helpers/moduleHelpers.js'; +export const taskName = 'Direct Change Helper Task'; +const debug = Debug(`faster-web-helper:${camelCase(moduleName)}:${camelCase(taskName)}`); const worktech = new WorkTechAPI(getConfigProperty('worktech')); const directChargeTransactionsConfig = getConfigProperty('modules.worktechUpdate.reports.w217'); async function _updateWorkOrderNumberMappings(report, data) { diff --git a/modules/worktechUpdate/tasks/directChargeHelperTask.ts b/modules/worktechUpdate/tasks/directChargeHelperTask.ts index b6a1b5f..bd579fa 100644 --- a/modules/worktechUpdate/tasks/directChargeHelperTask.ts +++ b/modules/worktechUpdate/tasks/directChargeHelperTask.ts @@ -10,6 +10,7 @@ import { timeStringToInteger } from '@cityssm/utils-datetime' import { WorkTechAPI } from '@cityssm/worktech-api' +import camelCase from 'camelcase' import Debug from 'debug' import { getConfigProperty } from '../../../helpers/functions.config.js' @@ -19,11 +20,12 @@ import addWorkOrderNumberMapping from '../database/addWorkOrderNumberMapping.js' import getReturnToVendorRecord from '../database/getReturnToVendorRecord.js' import getWorkOrderNumberMapping from '../database/getWorkOrderNumberMapping.js' import updateWorkOrderNumberMapping from '../database/updateWorkOrderNumberMapping.js' +import { moduleName } from '../helpers/moduleHelpers.js' import type { ReturnToVendorRecord } from '../worktechUpdateTypes.js' -export const taskName = 'directChangeHelperTask' +export const taskName = 'Direct Change Helper Task' -const debug = Debug(`faster-web-helper:worktechUpdate:${taskName}`) +const debug = Debug(`faster-web-helper:${camelCase(moduleName)}:${camelCase(taskName)}`) const worktech = new WorkTechAPI(getConfigProperty('worktech')) diff --git a/modules/worktechUpdate/tasks/inventoryTransactionsTask.d.ts b/modules/worktechUpdate/tasks/inventoryTransactionsTask.d.ts index 67d5b1d..5dbee60 100644 --- a/modules/worktechUpdate/tasks/inventoryTransactionsTask.d.ts +++ b/modules/worktechUpdate/tasks/inventoryTransactionsTask.d.ts @@ -1,2 +1,2 @@ -export declare const taskName = "inventoryTransactionsTask"; +export declare const taskName = "Inventory Transactions Task"; export default function runInventoryTransactionsTask(): Promise; diff --git a/modules/worktechUpdate/tasks/inventoryTransactionsTask.js b/modules/worktechUpdate/tasks/inventoryTransactionsTask.js index 68845a8..4f73d50 100644 --- a/modules/worktechUpdate/tasks/inventoryTransactionsTask.js +++ b/modules/worktechUpdate/tasks/inventoryTransactionsTask.js @@ -1,14 +1,16 @@ import { parseW223ExcelReport } from '@cityssm/faster-api/xlsxReports.js'; import { dateStringToInteger } from '@cityssm/utils-datetime'; import { WorkTechAPI } from '@cityssm/worktech-api'; +import camelCase from 'camelcase'; import Debug from 'debug'; import { getConfigProperty } from '../../../helpers/functions.config.js'; import { downloadFilesToTemp } from '../../../helpers/functions.sftp.js'; import getReturnToVendorRecord from '../database/getReturnToVendorRecord.js'; import getWorkOrderNumberMapping from '../database/getWorkOrderNumberMapping.js'; +import { moduleName } from '../helpers/moduleHelpers.js'; import { buildWorkOrderResourceDescriptionHash, getOrCreateStoreroomResourceItem, getWorkOrderResources } from '../helpers/worktechHelpers.js'; -export const taskName = 'inventoryTransactionsTask'; -const debug = Debug(`faster-web-helper:worktechUpdate:${taskName}`); +export const taskName = 'Inventory Transactions Task'; +const debug = Debug(`faster-web-helper:${camelCase(moduleName)}:${camelCase(taskName)}`); const worktech = new WorkTechAPI(getConfigProperty('worktech')); const inventoryTransactionsConfig = getConfigProperty('modules.worktechUpdate.reports.w223'); export default async function runInventoryTransactionsTask() { @@ -119,7 +121,7 @@ export default async function runInventoryTransactionsTask() { .filter((possibleResourceItem) => { return (possibleResourceItem.itemId === worktechStoreroomResourceItem.itemId && - possibleResourceItem.workDescription.includes(transactionData.itemNumber) === true && + possibleResourceItem.workDescription.includes(transactionData.itemNumber) && possibleResourceItem.quantity > 0 && possibleResourceItem.unitPrice === transactionData.unitTrueCost); diff --git a/modules/worktechUpdate/tasks/inventoryTransactionsTask.ts b/modules/worktechUpdate/tasks/inventoryTransactionsTask.ts index 23db61a..8a00464 100644 --- a/modules/worktechUpdate/tasks/inventoryTransactionsTask.ts +++ b/modules/worktechUpdate/tasks/inventoryTransactionsTask.ts @@ -1,12 +1,14 @@ import { parseW223ExcelReport } from '@cityssm/faster-api/xlsxReports.js' import { type DateString, dateStringToInteger } from '@cityssm/utils-datetime' import { WorkTechAPI } from '@cityssm/worktech-api' +import camelCase from 'camelcase' import Debug from 'debug' import { getConfigProperty } from '../../../helpers/functions.config.js' import { downloadFilesToTemp } from '../../../helpers/functions.sftp.js' import getReturnToVendorRecord from '../database/getReturnToVendorRecord.js' import getWorkOrderNumberMapping from '../database/getWorkOrderNumberMapping.js' +import { moduleName } from '../helpers/moduleHelpers.js' import { type W223HashableTransactionReportData, buildWorkOrderResourceDescriptionHash, @@ -14,9 +16,9 @@ import { getWorkOrderResources } from '../helpers/worktechHelpers.js' -export const taskName = 'inventoryTransactionsTask' +export const taskName = 'Inventory Transactions Task' -const debug = Debug(`faster-web-helper:worktechUpdate:${taskName}`) +const debug = Debug(`faster-web-helper:${camelCase(moduleName)}:${camelCase(taskName)}`) const worktech = new WorkTechAPI(getConfigProperty('worktech')) @@ -198,7 +200,7 @@ export default async function runInventoryTransactionsTask(): Promise { worktechStoreroomResourceItem.itemId && possibleResourceItem.workDescription.includes( transactionData.itemNumber - ) === true && + ) && possibleResourceItem.quantity > 0 && possibleResourceItem.unitPrice === transactionData.unitTrueCost diff --git a/package-lock.json b/package-lock.json index cb7fc33..aecd90c 100644 --- a/package-lock.json +++ b/package-lock.json @@ -15,6 +15,7 @@ "@cityssm/worktech-api": "^0.3.2", "basic-ftp": "^5.0.5", "better-sqlite3": "^11.1.2", + "camelcase": "^8.0.0", "debug": "^4.3.5", "exit-hook": "^4.0.0", "node-schedule": "^2.1.1" @@ -1430,6 +1431,17 @@ "node": ">=6" } }, + "node_modules/camelcase": { + "version": "8.0.0", + "resolved": "https://registry.npmjs.org/camelcase/-/camelcase-8.0.0.tgz", + "integrity": "sha512-8WB3Jcas3swSvjIeA2yvCJ+Miyz5l1ZmB6HFb9R1317dt9LCQoswg/BGrmAmkWVEszSrrg4RwmO46qIm2OEnSA==", + "engines": { + "node": ">=16" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, "node_modules/caniuse-lite": { "version": "1.0.30001640", "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001640.tgz", diff --git a/package.json b/package.json index b5ea245..32ebfd6 100644 --- a/package.json +++ b/package.json @@ -24,6 +24,7 @@ "@cityssm/worktech-api": "^0.3.2", "basic-ftp": "^5.0.5", "better-sqlite3": "^11.1.2", + "camelcase": "^8.0.0", "debug": "^4.3.5", "exit-hook": "^4.0.0", "node-schedule": "^2.1.1" diff --git a/types/configTypes.d.ts b/types/configTypes.d.ts index 9e65774..a4d9eed 100644 --- a/types/configTypes.d.ts +++ b/types/configTypes.d.ts @@ -9,11 +9,13 @@ export interface Config { worktechUpdate?: ConfigModule; }; } -type ConfigModule = ({ +type ConfigModule = { + runOnStartup?: boolean; +} & (({ isEnabled: false; } & Partial) | ({ isEnabled: true; -} & T); +} & T)); export interface ConfigFtpPath { directory: string; filePrefix?: string; diff --git a/types/configTypes.ts b/types/configTypes.ts index 132830c..4672f92 100644 --- a/types/configTypes.ts +++ b/types/configTypes.ts @@ -13,13 +13,16 @@ export interface Config { } } -type ConfigModule = +type ConfigModule = { + runOnStartup?: boolean +} & ( | ({ isEnabled: false } & Partial) | ({ isEnabled: true } & T) +) export interface ConfigFtpPath { directory: string