@betterinternship/core 2.31.0 → 2.32.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -4,3 +4,4 @@ export * from './lib/forms/index.js';
4
4
  export * from './lib/partners/forms/index.js';
5
5
  export * from './lib/links/index.js';
6
6
  export * from './lib/auth/index.js';
7
+ export * from './lib/config/index.js';
package/dist/index.js CHANGED
@@ -4,4 +4,5 @@ export * from './lib/forms/index.js';
4
4
  export * from './lib/partners/forms/index.js';
5
5
  export * from './lib/links/index.js';
6
6
  export * from './lib/auth/index.js';
7
+ export * from './lib/config/index.js';
7
8
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC;AAC7B,cAAc,sBAAsB,CAAC;AACrC,cAAc,sBAAsB,CAAC;AACrC,cAAc,+BAA+B,CAAC;AAC9C,cAAc,sBAAsB,CAAC;AACrC,cAAc,qBAAqB,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC;AAC7B,cAAc,sBAAsB,CAAC;AACrC,cAAc,sBAAsB,CAAC;AACrC,cAAc,+BAA+B,CAAC;AAC9C,cAAc,sBAAsB,CAAC;AACrC,cAAc,qBAAqB,CAAC;AACpC,cAAc,uBAAuB,CAAC"}
@@ -0,0 +1,6 @@
1
+ type CronModule = typeof import('cron');
2
+ export declare const loadCron: () => Promise<CronModule>;
3
+ export declare const isValidCronExpression: (expression: string) => Promise<boolean>;
4
+ export declare const nextRunTimes: (expression: string, timeZone: string | undefined, count: number) => Promise<string[]>;
5
+ export declare const shortestGapMinutes: (expression: string, timeZone: string | undefined, samples?: number) => Promise<number>;
6
+ export {};
@@ -0,0 +1,22 @@
1
+ let cronModule;
2
+ export const loadCron = () => (cronModule ??= import('cron'));
3
+ export const isValidCronExpression = async (expression) => {
4
+ const { validateCronExpression } = await loadCron();
5
+ return validateCronExpression(expression).valid;
6
+ };
7
+ export const nextRunTimes = async (expression, timeZone, count) => {
8
+ const { CronTime } = await loadCron();
9
+ const times = new CronTime(expression, timeZone).sendAt(count);
10
+ return times.map((time) => time.toISO() ?? '');
11
+ };
12
+ export const shortestGapMinutes = async (expression, timeZone, samples = 8) => {
13
+ const { CronTime } = await loadCron();
14
+ const times = new CronTime(expression, timeZone).sendAt(samples);
15
+ let shortest = Number.POSITIVE_INFINITY;
16
+ for (let i = 1; i < times.length; i++) {
17
+ const gap = times[i].toMillis() - times[i - 1].toMillis();
18
+ shortest = Math.min(shortest, gap / 60_000);
19
+ }
20
+ return shortest;
21
+ };
22
+ //# sourceMappingURL=cron.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cron.js","sourceRoot":"","sources":["../../../lib/config/cron.ts"],"names":[],"mappings":"AAOA,IAAI,UAA2C,CAAC;AAEhD,MAAM,CAAC,MAAM,QAAQ,GAAG,GAAwB,EAAE,CAChD,CAAC,UAAU,KAAK,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC;AAGlC,MAAM,CAAC,MAAM,qBAAqB,GAAG,KAAK,EACxC,UAAkB,EACA,EAAE;IACpB,MAAM,EAAE,sBAAsB,EAAE,GAAG,MAAM,QAAQ,EAAE,CAAC;IACpD,OAAO,sBAAsB,CAAC,UAAU,CAAC,CAAC,KAAK,CAAC;AAClD,CAAC,CAAC;AAOF,MAAM,CAAC,MAAM,YAAY,GAAG,KAAK,EAC/B,UAAkB,EAClB,QAA4B,EAC5B,KAAa,EACM,EAAE;IACrB,MAAM,EAAE,QAAQ,EAAE,GAAG,MAAM,QAAQ,EAAE,CAAC;IACtC,MAAM,KAAK,GAAG,IAAI,QAAQ,CAAC,UAAU,EAAE,QAAQ,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IAC/D,OAAO,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;AACjD,CAAC,CAAC;AAOF,MAAM,CAAC,MAAM,kBAAkB,GAAG,KAAK,EACrC,UAAkB,EAClB,QAA4B,EAC5B,OAAO,GAAG,CAAC,EACM,EAAE;IACnB,MAAM,EAAE,QAAQ,EAAE,GAAG,MAAM,QAAQ,EAAE,CAAC;IACtC,MAAM,KAAK,GAAG,IAAI,QAAQ,CAAC,UAAU,EAAE,QAAQ,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;IACjE,IAAI,QAAQ,GAAG,MAAM,CAAC,iBAAiB,CAAC;IACxC,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,KAAK,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;QACtC,MAAM,GAAG,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC,QAAQ,EAAE,GAAG,KAAK,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,QAAQ,EAAE,CAAC;QAC1D,QAAQ,GAAG,IAAI,CAAC,GAAG,CAAC,QAAQ,EAAE,GAAG,GAAG,MAAM,CAAC,CAAC;IAC9C,CAAC;IACD,OAAO,QAAQ,CAAC;AAClB,CAAC,CAAC"}
@@ -0,0 +1,5 @@
1
+ export * from './registry.js';
2
+ export * from './reader.js';
3
+ export * from './parse.js';
4
+ export * from './scheduler.js';
5
+ export { nextRunTimes } from './cron.js';
@@ -0,0 +1,6 @@
1
+ export * from './registry.js';
2
+ export * from './reader.js';
3
+ export * from './parse.js';
4
+ export * from './scheduler.js';
5
+ export { nextRunTimes } from './cron.js';
6
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../lib/config/index.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAC;AAC9B,cAAc,aAAa,CAAC;AAC5B,cAAc,YAAY,CAAC;AAC3B,cAAc,gBAAgB,CAAC;AAC/B,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC"}
@@ -0,0 +1,11 @@
1
+ import type { ConfigDef, ConfigRuntimeValue } from './registry.js';
2
+ export type ParseResult = {
3
+ ok: true;
4
+ value: ConfigRuntimeValue;
5
+ canonical: string;
6
+ } | {
7
+ ok: false;
8
+ error: string;
9
+ };
10
+ export declare const parseStrict: (def: ConfigDef, rawInput: string) => Promise<ParseResult>;
11
+ export declare const parseLenientEnv: (def: ConfigDef, rawInput: string) => Promise<ConfigRuntimeValue | undefined>;
@@ -0,0 +1,89 @@
1
+ import { isValidCronExpression, shortestGapMinutes } from './cron.js';
2
+ const fail = (error) => ({ ok: false, error });
3
+ const ok = (value, canonical) => ({
4
+ ok: true,
5
+ value,
6
+ canonical,
7
+ });
8
+ const WHOLE_NUMBER = /^-?\d+$/;
9
+ const describeGap = (minutes) => minutes % 1440 === 0
10
+ ? `${minutes / 1440} day(s)`
11
+ : minutes % 60 === 0
12
+ ? `${minutes / 60} hour(s)`
13
+ : `${minutes} minute(s)`;
14
+ export const parseStrict = async (def, rawInput) => {
15
+ const raw = rawInput.trim();
16
+ switch (def.type) {
17
+ case 'int': {
18
+ if (!WHOLE_NUMBER.test(raw))
19
+ return fail('Enter a whole number.');
20
+ const value = Number(raw);
21
+ if (value < def.min || value > def.max)
22
+ return fail(`Enter a number from ${def.min} to ${def.max}.`);
23
+ return ok(value, String(value));
24
+ }
25
+ case 'bool': {
26
+ if (raw !== 'true' && raw !== 'false')
27
+ return fail('Enter true or false.');
28
+ return ok(raw === 'true', raw);
29
+ }
30
+ case 'enum': {
31
+ if (!def.options.includes(raw))
32
+ return fail(`Choose one of: ${def.options.join(', ')}.`);
33
+ return ok(raw, raw);
34
+ }
35
+ case 'int_list': {
36
+ const parts = raw.split(',').map((part) => part.trim());
37
+ if (parts.length === 0 || parts.length > def.maxItems)
38
+ return fail(`Enter 1 to ${def.maxItems} numbers, separated by commas.`);
39
+ if (!parts.every((part) => WHOLE_NUMBER.test(part)))
40
+ return fail('Enter whole numbers separated by commas, like 30,7,1.');
41
+ const values = parts.map(Number);
42
+ if (values.some((value) => value < def.min || value > def.max))
43
+ return fail(`Each number must be from ${def.min} to ${def.max}.`);
44
+ if (new Set(values).size !== values.length)
45
+ return fail('Each number can only appear once.');
46
+ return ok(values, values.join(','));
47
+ }
48
+ case 'cron': {
49
+ const expression = raw.split(/\s+/).join(' ');
50
+ if (expression.split(' ').length !== 5)
51
+ return fail('Enter a cron expression with 5 fields (minute hour day month weekday), like 0 8 * * *.');
52
+ if (!(await isValidCronExpression(expression)))
53
+ return fail('That is not a valid cron expression.');
54
+ const gap = await shortestGapMinutes(expression, def.timeZone);
55
+ if (gap < def.minIntervalMinutes)
56
+ return fail(`This would run too often: at most once every ${describeGap(def.minIntervalMinutes)} is allowed for this job.`);
57
+ return ok(expression, expression);
58
+ }
59
+ }
60
+ };
61
+ export const parseLenientEnv = async (def, rawInput) => {
62
+ const raw = rawInput.trim();
63
+ if (!raw)
64
+ return undefined;
65
+ switch (def.type) {
66
+ case 'int': {
67
+ const parsed = Number(raw);
68
+ return Number.isFinite(parsed) && parsed > 0
69
+ ? Math.floor(parsed)
70
+ : undefined;
71
+ }
72
+ case 'bool':
73
+ return raw === 'true' ? true : raw === 'false' ? false : undefined;
74
+ case 'enum':
75
+ return def.options.includes(raw) ? raw : undefined;
76
+ case 'int_list': {
77
+ const values = raw
78
+ .split(',')
79
+ .map((part) => Number.parseInt(part.trim(), 10))
80
+ .filter((value) => Number.isFinite(value));
81
+ return values.length ? values : undefined;
82
+ }
83
+ case 'cron': {
84
+ const expression = raw.split(/\s+/).join(' ');
85
+ return (await isValidCronExpression(expression)) ? expression : undefined;
86
+ }
87
+ }
88
+ };
89
+ //# sourceMappingURL=parse.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"parse.js","sourceRoot":"","sources":["../../../lib/config/parse.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,qBAA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
+ import { type ConfigKey, type ConfigValue } from './registry.js';
2
+ export type ConfigSource = 'db' | 'env' | 'default';
3
+ export interface ConfigLogger {
4
+ log(message: string): void;
5
+ warn(message: string): void;
6
+ error(message: string): void;
7
+ }
8
+ export declare const getConfig: <K extends ConfigKey>(key: K, logger?: ConfigLogger) => Promise<ConfigValue<K>>;
9
+ export declare const getConfigWithSource: <K extends ConfigKey>(key: K, logger?: ConfigLogger, waitForFresh?: boolean) => Promise<{
10
+ value: ConfigValue<K>;
11
+ source: ConfigSource;
12
+ }>;
13
+ export declare const logConfig: (keys: readonly ConfigKey[], logger?: ConfigLogger) => Promise<void>;
14
+ export declare const reloadConfig: () => Promise<void>;
15
+ export declare const resetConfigCacheForTests: () => void;
@@ -0,0 +1,132 @@
1
+ import { ENV } from '../env.js';
2
+ import { getInternalDb } from '../auth/db.js';
3
+ import { CONFIG_REGISTRY, } from './registry.js';
4
+ import { parseLenientEnv, parseStrict } from './parse.js';
5
+ const consoleLogger = {
6
+ log: (message) => console.log(`[config] ${message}`),
7
+ warn: (message) => console.warn(`[config] ${message}`),
8
+ error: (message) => console.error(`[config] ${message}`),
9
+ };
10
+ const TTL_MS = 30_000;
11
+ const RETRY_MS = 10_000;
12
+ const FIRST_LOAD_TIMEOUT_MS = 8_000;
13
+ const RETRY_LOAD_TIMEOUT_MS = 2_000;
14
+ const BACKGROUND_LOAD_TIMEOUT_MS = 10_000;
15
+ let rows = new Map();
16
+ let hasLoaded = false;
17
+ let expiresAt = 0;
18
+ let loading;
19
+ let failing = false;
20
+ let attempted = false;
21
+ const warned = new Set();
22
+ const warnOnce = (logger, id, message) => {
23
+ if (warned.has(id))
24
+ return;
25
+ warned.add(id);
26
+ logger.warn(message);
27
+ };
28
+ const withTimeout = (work, ms) => new Promise((resolve, reject) => {
29
+ const timer = setTimeout(() => reject(new Error(`timed out after ${ms} ms`)), ms);
30
+ work.then((value) => {
31
+ clearTimeout(timer);
32
+ resolve(value);
33
+ }, (error) => {
34
+ clearTimeout(timer);
35
+ reject(error instanceof Error ? error : new Error(String(error)));
36
+ });
37
+ });
38
+ const fetchRows = async () => {
39
+ const db = await getInternalDb();
40
+ const result = await db
41
+ .selectFrom('internal.app_config')
42
+ .select(['key', 'value'])
43
+ .execute();
44
+ return new Map(result.map((row) => [row.key, row.value]));
45
+ };
46
+ const refresh = () => (loading ??= (async () => {
47
+ const timeoutMs = hasLoaded
48
+ ? BACKGROUND_LOAD_TIMEOUT_MS
49
+ : attempted
50
+ ? RETRY_LOAD_TIMEOUT_MS
51
+ : FIRST_LOAD_TIMEOUT_MS;
52
+ attempted = true;
53
+ try {
54
+ rows = await withTimeout(fetchRows(), timeoutMs);
55
+ hasLoaded = true;
56
+ expiresAt = Date.now() + TTL_MS;
57
+ if (failing) {
58
+ failing = false;
59
+ consoleLogger.log('Reading internal.app_config works again.');
60
+ }
61
+ }
62
+ catch (error) {
63
+ expiresAt = Date.now() + RETRY_MS;
64
+ if (!failing) {
65
+ failing = true;
66
+ consoleLogger.warn(`Could not read internal.app_config (${error instanceof Error ? error.message : String(error)}); using ${hasLoaded ? 'the last values read' : 'env and defaults'}.`);
67
+ }
68
+ }
69
+ finally {
70
+ loading = undefined;
71
+ }
72
+ })());
73
+ const ensureFresh = async (waitForFresh) => {
74
+ if (Date.now() < expiresAt)
75
+ return;
76
+ if (hasLoaded && !waitForFresh) {
77
+ void refresh();
78
+ return;
79
+ }
80
+ await refresh();
81
+ };
82
+ const resolve = async (key, logger) => {
83
+ const def = CONFIG_REGISTRY[key];
84
+ const stored = rows.get(key);
85
+ if (stored !== undefined) {
86
+ const parsed = await parseStrict(def, stored);
87
+ if (parsed.ok)
88
+ return { value: parsed.value, source: 'db' };
89
+ warnOnce(logger, `${key}|db|${stored}`, `Ignoring the stored value for ${key}: ${parsed.error}`);
90
+ }
91
+ const envValue = def.env ? ENV[def.env] : undefined;
92
+ if (envValue) {
93
+ const parsed = await parseLenientEnv(def, envValue);
94
+ if (parsed !== undefined)
95
+ return { value: parsed, source: 'env' };
96
+ warnOnce(logger, `${key}|env|${envValue}`, `Ignoring ${def.env}="${envValue}" for ${key}: not a usable value. Using the default.`);
97
+ }
98
+ return {
99
+ value: typeof def.default === 'object' ? [...def.default] : def.default,
100
+ source: 'default',
101
+ };
102
+ };
103
+ export const getConfig = async (key, logger = consoleLogger) => {
104
+ await ensureFresh(false);
105
+ const { value } = await resolve(key, logger);
106
+ return value;
107
+ };
108
+ export const getConfigWithSource = async (key, logger = consoleLogger, waitForFresh = false) => {
109
+ await ensureFresh(waitForFresh);
110
+ const resolved = await resolve(key, logger);
111
+ return { value: resolved.value, source: resolved.source };
112
+ };
113
+ export const logConfig = async (keys, logger = consoleLogger) => {
114
+ for (const key of keys) {
115
+ const { value, source } = await getConfigWithSource(key, logger);
116
+ logger.log(`${key} = ${JSON.stringify(value)} (${source})`);
117
+ }
118
+ };
119
+ export const reloadConfig = async () => {
120
+ expiresAt = 0;
121
+ await refresh();
122
+ };
123
+ export const resetConfigCacheForTests = () => {
124
+ rows = new Map();
125
+ hasLoaded = false;
126
+ expiresAt = 0;
127
+ loading = undefined;
128
+ failing = false;
129
+ attempted = false;
130
+ warned.clear();
131
+ };
132
+ //# sourceMappingURL=reader.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"reader.js","sourceRoot":"","sources":["../../../lib/config/reader.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,WAAW,CAAC;AAChC,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAC9C,OAAO,EACL,eAAe,GAKhB,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,eAAe,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAY1D,MAAM,aAAa,GAAiB;IAClC,GAAG,EAAE,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,GAAG,CAAC,YAAY,OAAO,EAAE,CAAC;IACpD,IAAI,EAAE,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,IAAI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AAE,MAAM,CAAC,CAAC;IAC5C,OAAO,EAAE,KAAK,EAAE,QAAQ,CAAC,KAAuB,EAAE,MAAM,EAAE,QAAQ,CAAC,MAAM,EAAE,CAAC;AAC9E,CAAC,CAAC;AAMF,MAAM,CAAC,MAAM,SAAS,GAAG,KAAK,EAC5B,IAA0B,EAC1B,SAAuB,aAAa,EACrB,EAAE;IACjB,KAAK,MAAM,GAAG,IAAI,IAAI,EAAE,CAAC;QACvB,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,MAAM,mBAAmB,CAAC,GAAG,EAAE,MAAM,CAAC,CAAC;QACjE,MAAM,CAAC,GAAG,CAAC,GAAG,GAAG,MAAM,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,KAAK,MAAM,GAAG,CAAC,CAAC;IAC9D,CAAC;AACH,CAAC,CAAC;AAGF,MAAM,CAAC,MAAM,YAAY,GAAG,KAAK,IAAmB,EAAE;IACpD,SAAS,GAAG,CAAC,CAAC;IACd,MAAM,OAAO,EAAE,CAAC;AAClB,CAAC,CAAC;AAGF,MAAM,CAAC,MAAM,wBAAwB,GAAG,GAAS,EAAE;IACjD,IAAI,GAAG,IAAI,GAAG,EAAE,CAAC;IACjB,SAAS,GAAG,KAAK,CAAC;IAClB,SAAS,GAAG,CAAC,CAAC;IACd,OAAO,GAAG,SAAS,CAAC;IACpB,OAAO,GAAG,KAAK,CAAC;IAChB,SAAS,GAAG,KAAK,CAAC;IAClB,MAAM,CAAC,KAAK,EAAE,CAAC;AACjB,CAAC,CAAC"}
@@ -0,0 +1,294 @@
1
+ export type ConfigGroup = 'Employer digests' | 'Stale listings' | 'Top pages' | 'Resumes' | 'Partners' | 'Docs jobs' | 'Employer stats';
2
+ interface ConfigDefBase {
3
+ env?: string;
4
+ group: ConfigGroup;
5
+ description: string;
6
+ }
7
+ export interface CronDef extends ConfigDefBase {
8
+ type: 'cron';
9
+ default: string;
10
+ timeZone?: string;
11
+ minIntervalMinutes: number;
12
+ }
13
+ export interface IntDef extends ConfigDefBase {
14
+ type: 'int';
15
+ default: number;
16
+ min: number;
17
+ max: number;
18
+ }
19
+ export interface BoolDef extends ConfigDefBase {
20
+ type: 'bool';
21
+ default: boolean;
22
+ }
23
+ export interface EnumDef extends ConfigDefBase {
24
+ type: 'enum';
25
+ options: readonly string[];
26
+ default: string;
27
+ }
28
+ export interface IntListDef extends ConfigDefBase {
29
+ type: 'int_list';
30
+ default: readonly number[];
31
+ min: number;
32
+ max: number;
33
+ maxItems: number;
34
+ }
35
+ export type ConfigDef = CronDef | IntDef | BoolDef | EnumDef | IntListDef;
36
+ export declare const CONFIG_REGISTRY: {
37
+ readonly 'career.digest.daily.cron': {
38
+ readonly type: "cron";
39
+ readonly env: "EMPLOYER_DIGEST_NOTIFICATION_INTERVAL";
40
+ readonly group: "Employer digests";
41
+ readonly description: "When the daily email of new applications goes out to employers.";
42
+ readonly default: "0 8 * * *";
43
+ readonly minIntervalMinutes: number;
44
+ };
45
+ readonly 'career.digest.shortlisted_reminder.cron': {
46
+ readonly type: "cron";
47
+ readonly env: "EMPLOYER_SHORTLISTED_REMINDER_NOTIFICATION_INTERVAL";
48
+ readonly group: "Employer digests";
49
+ readonly description: "When the shortlisted-applicants reminder is checked. It only sends in odd ISO weeks (Manila time).";
50
+ readonly default: "0 8 * * 1";
51
+ readonly timeZone: "Asia/Manila";
52
+ readonly minIntervalMinutes: number;
53
+ };
54
+ readonly 'career.digest.summary.cron': {
55
+ readonly type: "cron";
56
+ readonly env: "EMPLOYER_DIGEST_SUMMARY_NOTIFICATION_INTERVAL";
57
+ readonly group: "Employer digests";
58
+ readonly description: "When the weekly digest summary is posted to Discord.";
59
+ readonly default: "0 9 * * 1";
60
+ readonly timeZone: "Asia/Manila";
61
+ readonly minIntervalMinutes: number;
62
+ };
63
+ readonly 'career.stale_sweep.cron': {
64
+ readonly type: "cron";
65
+ readonly env: "STALE_SWEEP_CRON";
66
+ readonly group: "Stale listings";
67
+ readonly description: "When the stale-listings sweep runs.";
68
+ readonly default: "0 8 * * *";
69
+ readonly minIntervalMinutes: number;
70
+ };
71
+ readonly 'career.stale_sweep.mode': {
72
+ readonly type: "enum";
73
+ readonly env: "STALE_SWEEP_MODE";
74
+ readonly group: "Stale listings";
75
+ readonly description: "off does nothing, dry_run only reports what it would pause, live pauses the listings.";
76
+ readonly options: readonly ["off", "dry_run", "live"];
77
+ readonly default: "off";
78
+ };
79
+ readonly 'career.stale_sweep.dormant_days': {
80
+ readonly type: "int";
81
+ readonly env: "STALE_DORMANT_DAYS";
82
+ readonly group: "Stale listings";
83
+ readonly description: "An employer with no logins for this many days is dormant.";
84
+ readonly default: 120;
85
+ readonly min: 1;
86
+ readonly max: 3650;
87
+ };
88
+ readonly 'career.stale_sweep.unresponsive_days': {
89
+ readonly type: "int";
90
+ readonly env: "STALE_UNRESPONSIVE_DAYS";
91
+ readonly group: "Stale listings";
92
+ readonly description: "An employer with no logins for this many days, and an applicant still waiting, is unresponsive.";
93
+ readonly default: 30;
94
+ readonly min: 1;
95
+ readonly max: 3650;
96
+ };
97
+ readonly 'career.stale_sweep.neglect_days': {
98
+ readonly type: "int";
99
+ readonly env: "STALE_NEGLECT_DAYS";
100
+ readonly group: "Stale listings";
101
+ readonly description: "A listing with an applicant untouched for this many days, and no recent activity, counts as neglected.";
102
+ readonly default: 30;
103
+ readonly min: 1;
104
+ readonly max: 3650;
105
+ };
106
+ readonly 'career.stale_sweep.max_employers_per_run': {
107
+ readonly type: "int";
108
+ readonly env: "STALE_SWEEP_MAX_EMPLOYERS_PER_RUN";
109
+ readonly group: "Stale listings";
110
+ readonly description: "The most employers one sweep acts on.";
111
+ readonly default: 25;
112
+ readonly min: 1;
113
+ readonly max: 1000;
114
+ };
115
+ readonly 'career.top_pages.weekly_cron': {
116
+ readonly type: "cron";
117
+ readonly env: "TOP_PAGES_WEEKLY_CRON";
118
+ readonly group: "Top pages";
119
+ readonly description: "When the Top pages are regenerated for the new week. The week rolls over at Sunday 00:00 Manila by default.";
120
+ readonly default: "0 0 * * 0";
121
+ readonly timeZone: "Asia/Manila";
122
+ readonly minIntervalMinutes: number;
123
+ };
124
+ readonly 'career.top_pages.regen_on_sweep': {
125
+ readonly type: "bool";
126
+ readonly env: "TOP_PAGES_REGEN_ON_SWEEP";
127
+ readonly group: "Top pages";
128
+ readonly description: "Regenerate the Top pages after each stale-listings sweep, so paused listings show as hibernating.";
129
+ readonly default: false;
130
+ };
131
+ readonly 'career.top_pages.warm_concurrency': {
132
+ readonly type: "int";
133
+ readonly env: "TOP_PAGES_WARM_CONCURRENCY";
134
+ readonly group: "Top pages";
135
+ readonly description: "How many pages are warmed at once after a regeneration.";
136
+ readonly default: 4;
137
+ readonly min: 1;
138
+ readonly max: 32;
139
+ };
140
+ readonly 'career.top_pages.warm_max': {
141
+ readonly type: "int";
142
+ readonly env: "TOP_PAGES_WARM_MAX";
143
+ readonly group: "Top pages";
144
+ readonly description: "The most pages warmed after a regeneration.";
145
+ readonly default: 500;
146
+ readonly min: 1;
147
+ readonly max: 5000;
148
+ };
149
+ readonly 'career.top_pages.warm_verify_delay_ms': {
150
+ readonly type: "int";
151
+ readonly env: "TOP_PAGES_WARM_VERIFY_DELAY_MS";
152
+ readonly group: "Top pages";
153
+ readonly description: "Milliseconds to wait before checking that the warmed pages are live.";
154
+ readonly default: 15000;
155
+ readonly min: 1;
156
+ readonly max: 300000;
157
+ };
158
+ readonly 'career.resumes.max_per_user': {
159
+ readonly type: "int";
160
+ readonly env: "MAX_RESUMES_ALLOWED";
161
+ readonly group: "Resumes";
162
+ readonly description: "The most resumes one student can have uploaded.";
163
+ readonly default: 5;
164
+ readonly min: 1;
165
+ readonly max: 100;
166
+ };
167
+ readonly 'partners.signature_expiry_sweep.cron': {
168
+ readonly type: "cron";
169
+ readonly env: "IOM_SIGNATURE_EXPIRY_SWEEP_CRON";
170
+ readonly group: "Partners";
171
+ readonly description: "When MOA requests whose signing link has passed its deadline are marked expired.";
172
+ readonly default: "0 * * * *";
173
+ readonly minIntervalMinutes: 60;
174
+ };
175
+ readonly 'partners.expiry_sweep.cron': {
176
+ readonly type: "cron";
177
+ readonly env: "IOM_EXPIRY_SWEEP_CRON";
178
+ readonly group: "Partners";
179
+ readonly description: "When MOAs past their expiry date are marked expired.";
180
+ readonly default: "0 * * * *";
181
+ readonly minIntervalMinutes: 60;
182
+ };
183
+ readonly 'partners.parked_request_sweep.cron': {
184
+ readonly type: "cron";
185
+ readonly env: "IOM_PARKED_REQUEST_SWEEP_CRON";
186
+ readonly group: "Partners";
187
+ readonly description: "When parked auto-requests left behind by a restart are picked up again.";
188
+ readonly default: "0 * * * *";
189
+ readonly minIntervalMinutes: 60;
190
+ };
191
+ readonly 'partners.listing_acceptance_sweep.cron': {
192
+ readonly type: "cron";
193
+ readonly env: "IOM_LISTING_ACCEPTANCE_SWEEP_CRON";
194
+ readonly group: "Partners";
195
+ readonly description: "When waiting listing invites are promoted to accepted.";
196
+ readonly default: "0 * * * *";
197
+ readonly minIntervalMinutes: 60;
198
+ };
199
+ readonly 'partners.daily_notifications.cron': {
200
+ readonly type: "cron";
201
+ readonly env: "IOM_DAILY_NOTIFICATION_CRON";
202
+ readonly group: "Partners";
203
+ readonly description: "When lapsed documents are cleared and the expiry reminders are sent.";
204
+ readonly default: "0 8 * * *";
205
+ readonly timeZone: "Asia/Manila";
206
+ readonly minIntervalMinutes: number;
207
+ };
208
+ readonly 'partners.expiry_reminder_days': {
209
+ readonly type: "int_list";
210
+ readonly env: "IOM_EXPIRY_REMINDER_DAYS";
211
+ readonly group: "Partners";
212
+ readonly description: "How many days before expiry a reminder is sent, comma-separated (for example 30,7,1).";
213
+ readonly default: readonly [30, 7, 1];
214
+ readonly min: 1;
215
+ readonly max: 365;
216
+ readonly maxItems: 10;
217
+ };
218
+ readonly 'partners.expiring_soon_days': {
219
+ readonly type: "int";
220
+ readonly env: "IOM_EXPIRING_SOON_DAYS";
221
+ readonly group: "Partners";
222
+ readonly description: "A MOA expiring within this many days is shown as expiring soon.";
223
+ readonly default: 30;
224
+ readonly min: 1;
225
+ readonly max: 365;
226
+ };
227
+ readonly 'partners.max_active_moas_per_pair': {
228
+ readonly type: "int";
229
+ readonly env: "IOM_MAX_ACTIVE_MOAS_PER_PAIR";
230
+ readonly group: "Partners";
231
+ readonly description: "The most active MOAs one university and company pair can hold.";
232
+ readonly default: 3;
233
+ readonly min: 1;
234
+ readonly max: 20;
235
+ };
236
+ readonly 'partners.max_bulk_invite_recipients': {
237
+ readonly type: "int";
238
+ readonly env: "IOM_MAX_BULK_INVITE_RECIPIENTS";
239
+ readonly group: "Partners";
240
+ readonly description: "The most companies one bulk invite can include.";
241
+ readonly default: 100;
242
+ readonly min: 1;
243
+ readonly max: 1000;
244
+ };
245
+ readonly 'docs.mq_jobs_sweep.cron': {
246
+ readonly type: "cron";
247
+ readonly group: "Docs jobs";
248
+ readonly description: "When finished and failed background jobs are cleared out.";
249
+ readonly default: "0 3 * * *";
250
+ readonly minIntervalMinutes: 60;
251
+ };
252
+ readonly 'docs.mq_jobs_sweep.done_retention_days': {
253
+ readonly type: "int";
254
+ readonly group: "Docs jobs";
255
+ readonly description: "Finished background jobs are kept this many days.";
256
+ readonly default: 7;
257
+ readonly min: 1;
258
+ readonly max: 365;
259
+ };
260
+ readonly 'docs.mq_jobs_sweep.failed_retention_days': {
261
+ readonly type: "int";
262
+ readonly group: "Docs jobs";
263
+ readonly description: "Failed background jobs are kept this many days.";
264
+ readonly default: 30;
265
+ readonly min: 1;
266
+ readonly max: 365;
267
+ };
268
+ readonly 'tools.employer_login_metrics.cron': {
269
+ readonly type: "cron";
270
+ readonly group: "Employer stats";
271
+ readonly description: "When the employer login numbers on the Stats page are refreshed.";
272
+ readonly default: "0 0 * * *";
273
+ readonly timeZone: "Asia/Manila";
274
+ readonly minIntervalMinutes: 60;
275
+ };
276
+ };
277
+ export type ConfigKey = keyof typeof CONFIG_REGISTRY;
278
+ type DefOf<K extends ConfigKey> = (typeof CONFIG_REGISTRY)[K];
279
+ export type ConfigValue<K extends ConfigKey> = DefOf<K> extends {
280
+ type: 'cron';
281
+ } ? string : DefOf<K> extends {
282
+ type: 'int';
283
+ } ? number : DefOf<K> extends {
284
+ type: 'bool';
285
+ } ? boolean : DefOf<K> extends {
286
+ type: 'int_list';
287
+ } ? number[] : DefOf<K> extends {
288
+ type: 'enum';
289
+ options: infer O;
290
+ } ? O extends readonly string[] ? O[number] : never : never;
291
+ export type ConfigRuntimeValue = string | number | boolean | number[];
292
+ export declare const CONFIG_KEYS: ConfigKey[];
293
+ export declare const isConfigKey: (key: string) => key is ConfigKey;
294
+ export {};