diff --git a/http/index.ts b/http/index.ts index 9eeaad0f..e68483a9 100644 --- a/http/index.ts +++ b/http/index.ts @@ -162,7 +162,7 @@ async function deleteRequest( return data; } -const getRequestStreamCallbackKeys = ['onWrite']; +const getRequestStreamCallbackKeys = ['onWrite'] as const; function createGetRequestStream(contentType: string) { return async ( diff --git a/lib/archive.ts b/lib/archive.ts index 0501ea4b..c483a974 100644 --- a/lib/archive.ts +++ b/lib/archive.ts @@ -16,7 +16,7 @@ type ZipData = { tmpDir: string; }; -const archiveCallbackKeys = ['init', 'copy']; +const archiveCallbackKeys = ['init', 'copy'] as const; async function extractZip( name: string, diff --git a/lib/cms/functions.ts b/lib/cms/functions.ts index 2115d662..92aee650 100644 --- a/lib/cms/functions.ts +++ b/lib/cms/functions.ts @@ -11,6 +11,14 @@ import { LogCallbacksArg } from '../../types/LogCallbacks'; const i18nKey = 'lib.cms.functions'; +const createFunctionCallbackKeys = [ + 'destPathAlreadyExists', + 'createdDest', + 'createdFunctionFile', + 'createdConfigFile', + 'success', +] as const; + type Config = { runtime: string; version: string; @@ -146,14 +154,6 @@ type FunctionOptions = { allowExistingFile?: boolean; }; -const createFunctionCallbackKeys = [ - 'destPathAlreadyExists', - 'createdDest', - 'createdFunctionFile', - 'createdConfigFile', - 'success', -]; - export async function createFunction( functionInfo: FunctionInfo, dest: string, diff --git a/lib/cms/modules.ts b/lib/cms/modules.ts index c8ce0e2b..0417f2de 100644 --- a/lib/cms/modules.ts +++ b/lib/cms/modules.ts @@ -15,6 +15,8 @@ import { PathInput } from '../../types/Modules'; const i18nKey = 'lib.cms.modules'; +const createModuleCallbackKeys = ['creatingPath', 'creatingModule'] as const; + // Ids for testing export const ValidationIds = { SRC_REQUIRED: 'SRC_REQUIRED', @@ -108,8 +110,6 @@ type ModuleDefinition = { global: boolean; }; -const createModuleCallbackKeys = ['creatingPath', 'creatingModule'] as const; - export async function createModule( moduleDefinition: ModuleDefinition, name: string, diff --git a/lib/cms/templates.ts b/lib/cms/templates.ts index ccdd2054..ff6b3aa7 100644 --- a/lib/cms/templates.ts +++ b/lib/cms/templates.ts @@ -7,6 +7,8 @@ import { LogCallbacksArg } from '../../types/LogCallbacks'; const i18nKey = 'lib.cms.templates'; +const templatesCallbackKeys = ['creatingFile'] as const; + // Matches the .html file extension, excluding module.html const TEMPLATE_EXTENSION_REGEX = new RegExp(/(? & Pick; const i18nKey = 'lib.fileManager'; -const uploadCallbackKeys = ['uploadSuccess']; +const uploadCallbackKeys = ['uploadSuccess'] as const; const downloadCallbackKeys = [ 'skippedExisting', 'fetchFolderStarted', 'fetchFolderSuccess', 'fetchFileStarted', 'fetchFileSuccess', -]; +] as const; export async function uploadFolder( accountId: number, diff --git a/lib/fileMapper.ts b/lib/fileMapper.ts index 6a6c7c4f..e81e6595 100644 --- a/lib/fileMapper.ts +++ b/lib/fileMapper.ts @@ -31,6 +31,14 @@ import { makeTypedLogger } from '../utils/logger'; const i18nKey = 'lib.fileMapper'; +const filemapperCallbackKeys = [ + 'skippedExisting', + 'wroteFolder', + 'completedFetch', + 'folderFetch', + 'completedFolderFetch', +] as const; + const queue = new PQueue({ concurrency: 10, }); @@ -187,8 +195,6 @@ async function skipExisting( return false; } -const filemapperCallbackKeys = ['skippedExisting', 'wroteFolder']; - async function fetchAndWriteFileStream( accountId: number, srcPath: string, diff --git a/lib/github.ts b/lib/github.ts index 08c0c07d..f65555c0 100644 --- a/lib/github.ts +++ b/lib/github.ts @@ -18,6 +18,8 @@ import { const i18nKey = 'lib.github'; +const cloneGithubRepoCallbackKeys = ['success'] as const; + type RepoPath = `${string}/${string}`; export async function fetchFileFromRepository( @@ -114,8 +116,6 @@ type CloneGithubRepoOptions = { sourceDir?: string; // The directory within the downloaded repo to write after extraction }; -const cloneGithubRepoCallbackKeys = ['success']; - export async function cloneGithubRepo( repoPath: RepoPath, dest: string, diff --git a/lib/oauth.ts b/lib/oauth.ts index e1464843..df35c4c7 100644 --- a/lib/oauth.ts +++ b/lib/oauth.ts @@ -11,6 +11,8 @@ import { updateAccountConfig, writeConfig } from '../config'; const i18nKey = 'lib.oauth'; +const addOauthToAccountConfigCallbackKeys = ['init', 'success'] as const; + const oauthManagers = new Map(); function writeOauthTokenInfo(accountConfig: FlatAccountFields): void { @@ -37,8 +39,6 @@ export function getOauthManager( return oauthManagers.get(accountId); } -const addOauthToAccountConfigCallbackKeys = ['init', 'success']; - export function addOauthToAccountConfig( oauth: OAuth2Manager, logCallbacks: LogCallbacksArg