Skip to Content
⚠️Active Development Notice: TimeTiles is under active development. Information may be placeholder content or not up-to-date.

web


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 typeof TRUST_LEVELS]


QuotaKey

QuotaKey = keyof typeof QUOTAS

Key identifying a quota in the QUOTAS registry.

Variables

TRUST_LEVELS

const TRUST_LEVELS: object

Trust levels for users, determining their access and resource limits.

Type Declaration

UNTRUSTED

readonly UNTRUSTED: 0 = 0

BASIC

readonly BASIC: 1 = 1

REGULAR

readonly REGULAR: 2 = 2

TRUSTED

readonly TRUSTED: 3 = 3

POWER_USER

readonly POWER_USER: 4 = 4

UNLIMITED

readonly UNLIMITED: 5 = 5


DEFAULT_QUOTAS

const DEFAULT_QUOTAS: Record<TrustLevel, UserQuotas>

Default quotas for each trust level. -1 indicates unlimited.


TRUST_LEVEL_LABELS

const TRUST_LEVEL_LABELS: Record<TrustLevel, string>

Trust level labels for UI display.


TRUST_LEVEL_DESCRIPTIONS

const TRUST_LEVEL_DESCRIPTIONS: Record<TrustLevel, string>

Trust level descriptions for UI tooltips.


QUOTAS

const QUOTAS: object

Registry of all quota types. Each key is used as the sole identifier when checking, incrementing, or decrementing quotas.

Type Declaration

ACTIVE_SCHEDULES

readonly ACTIVE_SCHEDULES: object

ACTIVE_SCHEDULES.limitField

readonly limitField: "maxActiveSchedules" = "maxActiveSchedules"

ACTIVE_SCHEDULES.usageField

readonly usageField: "currentActiveSchedules" = "currentActiveSchedules"

ACTIVE_SCHEDULES.daily

readonly daily: false = false

ACTIVE_SCHEDULES.errorMessage()

readonly errorMessage: (current, limit) => string

Parameters
current

number

limit

number

Returns

string

URL_FETCHES_PER_DAY

readonly URL_FETCHES_PER_DAY: object

URL_FETCHES_PER_DAY.limitField

readonly limitField: "maxUrlFetchesPerDay" = "maxUrlFetchesPerDay"

URL_FETCHES_PER_DAY.usageField

readonly usageField: "urlFetchesToday" = "urlFetchesToday"

URL_FETCHES_PER_DAY.daily

readonly daily: true = true

URL_FETCHES_PER_DAY.errorMessage()

readonly errorMessage: (current, limit) => string

Parameters
current

number

limit

number

Returns

string

FILE_UPLOADS_PER_DAY

readonly FILE_UPLOADS_PER_DAY: object

FILE_UPLOADS_PER_DAY.limitField

readonly limitField: "maxFileUploadsPerDay" = "maxFileUploadsPerDay"

FILE_UPLOADS_PER_DAY.usageField

readonly usageField: "fileUploadsToday" = "fileUploadsToday"

FILE_UPLOADS_PER_DAY.daily

readonly daily: true = true

FILE_UPLOADS_PER_DAY.errorMessage()

readonly errorMessage: (current, limit) => string

Parameters
current

number

limit

number

Returns

string

EVENTS_PER_IMPORT

readonly EVENTS_PER_IMPORT: object

EVENTS_PER_IMPORT.limitField

readonly limitField: "maxEventsPerImport" = "maxEventsPerImport"

EVENTS_PER_IMPORT.usageField

readonly usageField: null = null

EVENTS_PER_IMPORT.daily

readonly daily: false = false

EVENTS_PER_IMPORT.errorMessage()

readonly errorMessage: (_current, limit) => string

Parameters
_current

number

limit

number

Returns

string

TOTAL_EVENTS

readonly TOTAL_EVENTS: object

TOTAL_EVENTS.limitField

readonly limitField: "maxTotalEvents" = "maxTotalEvents"

TOTAL_EVENTS.usageField

readonly usageField: "totalEventsCreated" = "totalEventsCreated"

TOTAL_EVENTS.daily

readonly daily: false = false

TOTAL_EVENTS.errorMessage()

readonly errorMessage: (current, limit) => string

Parameters
current

number

limit

number

Returns

string

IMPORT_JOBS_PER_DAY

readonly IMPORT_JOBS_PER_DAY: object

IMPORT_JOBS_PER_DAY.limitField

readonly limitField: "maxImportJobsPerDay" = "maxImportJobsPerDay"

IMPORT_JOBS_PER_DAY.usageField

readonly usageField: "importJobsToday" = "importJobsToday"

IMPORT_JOBS_PER_DAY.daily

readonly daily: true = true

IMPORT_JOBS_PER_DAY.errorMessage()

readonly errorMessage: (current, limit) => string

Parameters
current

number

limit

number

Returns

string

FILE_SIZE_MB

readonly FILE_SIZE_MB: object

FILE_SIZE_MB.limitField

readonly limitField: "maxFileSizeMB" = "maxFileSizeMB"

FILE_SIZE_MB.usageField

readonly usageField: null = null

FILE_SIZE_MB.daily

readonly daily: false = false

FILE_SIZE_MB.errorMessage()

readonly errorMessage: (_current, limit) => string

Parameters
_current

number

limit

number

Returns

string

CATALOGS_PER_USER

readonly CATALOGS_PER_USER: object

CATALOGS_PER_USER.limitField

readonly limitField: "maxCatalogsPerUser" = "maxCatalogsPerUser"

CATALOGS_PER_USER.usageField

readonly usageField: "currentCatalogs" = "currentCatalogs"

CATALOGS_PER_USER.daily

readonly daily: false = false

CATALOGS_PER_USER.errorMessage()

readonly errorMessage: (current, limit) => string

Parameters
current

number

limit

number

Returns

string


RATE_LIMITS_BY_TRUST_LEVEL

const RATE_LIMITS_BY_TRUST_LEVEL: object

Rate limit configurations by trust level. Each level has progressively more generous limits.

Type Declaration

0

readonly 0: object

0.FILE_UPLOAD

readonly FILE_UPLOAD: object

0.FILE_UPLOAD.windows

readonly windows: readonly [{ limit: 1; windowMs: number; name: "burst"; }, { limit: 1; windowMs: number; name: "hourly"; }, { limit: 1; windowMs: number; name: "daily"; }]

0.API_GENERAL

readonly API_GENERAL: object

0.API_GENERAL.windows

readonly windows: readonly [{ limit: 1; windowMs: 1000; name: "burst"; }, { limit: 10; windowMs: number; name: "hourly"; }]

1

readonly 1: object

1.FILE_UPLOAD

readonly FILE_UPLOAD: object

1.FILE_UPLOAD.windows

readonly windows: readonly [{ limit: 1; windowMs: number; name: "burst"; }, { limit: 3; windowMs: number; name: "hourly"; }, { limit: 3; windowMs: number; name: "daily"; }]

1.API_GENERAL

readonly API_GENERAL: object

1.API_GENERAL.windows

readonly windows: readonly [{ limit: 2; windowMs: 1000; name: "burst"; }, { limit: 30; windowMs: number; name: "hourly"; }]

2

readonly 2: object

2.FILE_UPLOAD

readonly FILE_UPLOAD: object

2.FILE_UPLOAD.windows

readonly windows: readonly [{ limit: 1; windowMs: number; name: "burst"; }, { limit: 5; windowMs: number; name: "hourly"; }, { limit: 20; windowMs: number; name: "daily"; }]

2.API_GENERAL

readonly API_GENERAL: object

2.API_GENERAL.windows

readonly windows: readonly [{ limit: 5; windowMs: 1000; name: "burst"; }, { limit: 50; windowMs: number; name: "hourly"; }]

3

readonly 3: object

3.FILE_UPLOAD

readonly FILE_UPLOAD: object

3.FILE_UPLOAD.windows

readonly windows: readonly [{ limit: 2; windowMs: number; name: "burst"; }, { limit: 20; windowMs: number; name: "hourly"; }, { limit: 50; windowMs: number; name: "daily"; }]

3.API_GENERAL

readonly API_GENERAL: object

3.API_GENERAL.windows

readonly windows: readonly [{ limit: 10; windowMs: 1000; name: "burst"; }, { limit: 200; windowMs: number; name: "hourly"; }]

4

readonly 4: object

4.FILE_UPLOAD

readonly FILE_UPLOAD: object

4.FILE_UPLOAD.windows

readonly windows: readonly [{ limit: 5; windowMs: number; name: "burst"; }, { limit: 100; windowMs: number; name: "hourly"; }, { limit: 200; windowMs: number; name: "daily"; }]

4.API_GENERAL

readonly API_GENERAL: object

4.API_GENERAL.windows

readonly windows: readonly [{ limit: 20; windowMs: 1000; name: "burst"; }, { limit: 1000; windowMs: number; name: "hourly"; }]

5

readonly 5: object

5.FILE_UPLOAD

readonly FILE_UPLOAD: object

5.FILE_UPLOAD.windows

readonly windows: readonly [{ limit: 10; windowMs: 1000; name: "burst"; }, { limit: 1000; windowMs: number; name: "hourly"; }]

5.API_GENERAL

readonly API_GENERAL: object

5.API_GENERAL.windows

readonly windows: 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

Returns

TrustLevel

Last updated on