web / lib/constants/quota-constants
lib/constants/quota-constants
Constants for the quota system.
This file defines trust levels, default quotas, and quota descriptors used throughout the application to control resource usage and enforce limits.
Each quota is defined as a single QuotaDescriptor in the QUOTAS registry, linking the limit field, usage field, daily flag, and error message in one place.
Interfaces
UserQuotas
User quota configuration interface.
Properties
maxActiveSchedules
maxActiveSchedules:
number
maxUrlFetchesPerDay
maxUrlFetchesPerDay:
number
maxFileUploadsPerDay
maxFileUploadsPerDay:
number
maxEventsPerImport
maxEventsPerImport:
number
maxTotalEvents
maxTotalEvents:
number
maxImportJobsPerDay
maxImportJobsPerDay:
number
maxFileSizeMB
maxFileSizeMB:
number
maxCatalogsPerUser
maxCatalogsPerUser:
number
UserUsage
User usage tracking interface.
Properties
currentActiveSchedules
currentActiveSchedules:
number
urlFetchesToday
urlFetchesToday:
number
fileUploadsToday
fileUploadsToday:
number
importJobsToday
importJobsToday:
number
totalEventsCreated
totalEventsCreated:
number
currentCatalogs
currentCatalogs:
number
lastResetDate
lastResetDate:
string
QuotaDescriptor
A quota descriptor links the limit field, usage tracking field, daily flag, and error message for a single quota type.
Properties
limitField
limitField: keyof
UserQuotas
Field name on UserQuotas (the ceiling).
usageField
usageField:
"urlFetchesToday"|"fileUploadsToday"|"importJobsToday"|"currentActiveSchedules"|"totalEventsCreated"|"currentCatalogs"|null
Field name on UserUsage (the counter), or null for check-only quotas (e.g. file size).
daily
daily:
boolean
Whether this quota resets daily at midnight UTC.
errorMessage()
errorMessage: (
current,limit) =>string
Human-readable error message when quota is exceeded.
Parameters
current
number
limit
number
Returns
string
Type Aliases
TrustLevel
TrustLevel = typeof
TRUST_LEVELS[keyof typeofTRUST_LEVELS]
QuotaKey
QuotaKey = keyof typeof
QUOTAS
Key identifying a quota in the QUOTAS registry.
Variables
TRUST_LEVELS
constTRUST_LEVELS:object
Trust levels for users, determining their access and resource limits.
Type Declaration
UNTRUSTED
readonlyUNTRUSTED:0=0
BASIC
readonlyBASIC:1=1
REGULAR
readonlyREGULAR:2=2
TRUSTED
readonlyTRUSTED:3=3
POWER_USER
readonlyPOWER_USER:4=4
UNLIMITED
readonlyUNLIMITED:5=5
DEFAULT_QUOTAS
constDEFAULT_QUOTAS:Record<TrustLevel,UserQuotas>
Default quotas for each trust level. -1 indicates unlimited.
TRUST_LEVEL_LABELS
constTRUST_LEVEL_LABELS:Record<TrustLevel,string>
Trust level labels for UI display.
TRUST_LEVEL_DESCRIPTIONS
constTRUST_LEVEL_DESCRIPTIONS:Record<TrustLevel,string>
Trust level descriptions for UI tooltips.
QUOTAS
constQUOTAS:object
Registry of all quota types. Each key is used as the sole identifier when checking, incrementing, or decrementing quotas.
Type Declaration
ACTIVE_SCHEDULES
readonlyACTIVE_SCHEDULES:object
ACTIVE_SCHEDULES.limitField
readonlylimitField:"maxActiveSchedules"="maxActiveSchedules"
ACTIVE_SCHEDULES.usageField
readonlyusageField:"currentActiveSchedules"="currentActiveSchedules"
ACTIVE_SCHEDULES.daily
readonlydaily:false=false
ACTIVE_SCHEDULES.errorMessage()
readonlyerrorMessage: (current,limit) =>string
Parameters
current
number
limit
number
Returns
string
URL_FETCHES_PER_DAY
readonlyURL_FETCHES_PER_DAY:object
URL_FETCHES_PER_DAY.limitField
readonlylimitField:"maxUrlFetchesPerDay"="maxUrlFetchesPerDay"
URL_FETCHES_PER_DAY.usageField
readonlyusageField:"urlFetchesToday"="urlFetchesToday"
URL_FETCHES_PER_DAY.daily
readonlydaily:true=true
URL_FETCHES_PER_DAY.errorMessage()
readonlyerrorMessage: (current,limit) =>string
Parameters
current
number
limit
number
Returns
string
FILE_UPLOADS_PER_DAY
readonlyFILE_UPLOADS_PER_DAY:object
FILE_UPLOADS_PER_DAY.limitField
readonlylimitField:"maxFileUploadsPerDay"="maxFileUploadsPerDay"
FILE_UPLOADS_PER_DAY.usageField
readonlyusageField:"fileUploadsToday"="fileUploadsToday"
FILE_UPLOADS_PER_DAY.daily
readonlydaily:true=true
FILE_UPLOADS_PER_DAY.errorMessage()
readonlyerrorMessage: (current,limit) =>string
Parameters
current
number
limit
number
Returns
string
EVENTS_PER_IMPORT
readonlyEVENTS_PER_IMPORT:object
EVENTS_PER_IMPORT.limitField
readonlylimitField:"maxEventsPerImport"="maxEventsPerImport"
EVENTS_PER_IMPORT.usageField
readonlyusageField:null=null
EVENTS_PER_IMPORT.daily
readonlydaily:false=false
EVENTS_PER_IMPORT.errorMessage()
readonlyerrorMessage: (_current,limit) =>string
Parameters
_current
number
limit
number
Returns
string
TOTAL_EVENTS
readonlyTOTAL_EVENTS:object
TOTAL_EVENTS.limitField
readonlylimitField:"maxTotalEvents"="maxTotalEvents"
TOTAL_EVENTS.usageField
readonlyusageField:"totalEventsCreated"="totalEventsCreated"
TOTAL_EVENTS.daily
readonlydaily:false=false
TOTAL_EVENTS.errorMessage()
readonlyerrorMessage: (current,limit) =>string
Parameters
current
number
limit
number
Returns
string
IMPORT_JOBS_PER_DAY
readonlyIMPORT_JOBS_PER_DAY:object
IMPORT_JOBS_PER_DAY.limitField
readonlylimitField:"maxImportJobsPerDay"="maxImportJobsPerDay"
IMPORT_JOBS_PER_DAY.usageField
readonlyusageField:"importJobsToday"="importJobsToday"
IMPORT_JOBS_PER_DAY.daily
readonlydaily:true=true
IMPORT_JOBS_PER_DAY.errorMessage()
readonlyerrorMessage: (current,limit) =>string
Parameters
current
number
limit
number
Returns
string
FILE_SIZE_MB
readonlyFILE_SIZE_MB:object
FILE_SIZE_MB.limitField
readonlylimitField:"maxFileSizeMB"="maxFileSizeMB"
FILE_SIZE_MB.usageField
readonlyusageField:null=null
FILE_SIZE_MB.daily
readonlydaily:false=false
FILE_SIZE_MB.errorMessage()
readonlyerrorMessage: (_current,limit) =>string
Parameters
_current
number
limit
number
Returns
string
CATALOGS_PER_USER
readonlyCATALOGS_PER_USER:object
CATALOGS_PER_USER.limitField
readonlylimitField:"maxCatalogsPerUser"="maxCatalogsPerUser"
CATALOGS_PER_USER.usageField
readonlyusageField:"currentCatalogs"="currentCatalogs"
CATALOGS_PER_USER.daily
readonlydaily:false=false
CATALOGS_PER_USER.errorMessage()
readonlyerrorMessage: (current,limit) =>string
Parameters
current
number
limit
number
Returns
string
RATE_LIMITS_BY_TRUST_LEVEL
constRATE_LIMITS_BY_TRUST_LEVEL:object
Rate limit configurations by trust level. Each level has progressively more generous limits.
Type Declaration
0
readonly0:object
0.FILE_UPLOAD
readonlyFILE_UPLOAD:object
0.FILE_UPLOAD.windows
readonlywindows: readonly [{ limit: 1; windowMs: number; name: "burst"; },{ limit: 1; windowMs: number; name: "hourly"; },{ limit: 1; windowMs: number; name: "daily"; }]
0.API_GENERAL
readonlyAPI_GENERAL:object
0.API_GENERAL.windows
readonlywindows: readonly [{ limit: 1; windowMs: 1000; name: "burst"; },{ limit: 10; windowMs: number; name: "hourly"; }]
1
readonly1:object
1.FILE_UPLOAD
readonlyFILE_UPLOAD:object
1.FILE_UPLOAD.windows
readonlywindows: readonly [{ limit: 1; windowMs: number; name: "burst"; },{ limit: 3; windowMs: number; name: "hourly"; },{ limit: 3; windowMs: number; name: "daily"; }]
1.API_GENERAL
readonlyAPI_GENERAL:object
1.API_GENERAL.windows
readonlywindows: readonly [{ limit: 2; windowMs: 1000; name: "burst"; },{ limit: 30; windowMs: number; name: "hourly"; }]
2
readonly2:object
2.FILE_UPLOAD
readonlyFILE_UPLOAD:object
2.FILE_UPLOAD.windows
readonlywindows: readonly [{ limit: 1; windowMs: number; name: "burst"; },{ limit: 5; windowMs: number; name: "hourly"; },{ limit: 20; windowMs: number; name: "daily"; }]
2.API_GENERAL
readonlyAPI_GENERAL:object
2.API_GENERAL.windows
readonlywindows: readonly [{ limit: 5; windowMs: 1000; name: "burst"; },{ limit: 50; windowMs: number; name: "hourly"; }]
3
readonly3:object
3.FILE_UPLOAD
readonlyFILE_UPLOAD:object
3.FILE_UPLOAD.windows
readonlywindows: readonly [{ limit: 2; windowMs: number; name: "burst"; },{ limit: 20; windowMs: number; name: "hourly"; },{ limit: 50; windowMs: number; name: "daily"; }]
3.API_GENERAL
readonlyAPI_GENERAL:object
3.API_GENERAL.windows
readonlywindows: readonly [{ limit: 10; windowMs: 1000; name: "burst"; },{ limit: 200; windowMs: number; name: "hourly"; }]
4
readonly4:object
4.FILE_UPLOAD
readonlyFILE_UPLOAD:object
4.FILE_UPLOAD.windows
readonlywindows: readonly [{ limit: 5; windowMs: number; name: "burst"; },{ limit: 100; windowMs: number; name: "hourly"; },{ limit: 200; windowMs: number; name: "daily"; }]
4.API_GENERAL
readonlyAPI_GENERAL:object
4.API_GENERAL.windows
readonlywindows: readonly [{ limit: 20; windowMs: 1000; name: "burst"; },{ limit: 1000; windowMs: number; name: "hourly"; }]
5
readonly5:object
5.FILE_UPLOAD
readonlyFILE_UPLOAD:object
5.FILE_UPLOAD.windows
readonlywindows: readonly [{ limit: 10; windowMs: 1000; name: "burst"; },{ limit: 1000; windowMs: number; name: "hourly"; }]
5.API_GENERAL
readonlyAPI_GENERAL:object
5.API_GENERAL.windows
readonlywindows: readonly [{ limit: 100; windowMs: 1000; name: "burst"; },{ limit: 10000; windowMs: number; name: "hourly"; }]
Functions
normalizeTrustLevel()
normalizeTrustLevel(
trustLevel):TrustLevel
Normalize a trust level value to a valid TrustLevel.
Parses the input as a strict integer and validates it against known trust levels. Falls back to TRUST_LEVELS.REGULAR for invalid or missing values.
Parameters
trustLevel
string | number | null | undefined