@ultimat3/core 31.15.0 → 31.17.0
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/CLAUDE.md +1 -0
- package/README.md +10 -0
- package/package.json +2 -2
- package/src/config-keys.ts +2 -1
- package/src/config.ts +8 -0
- package/src/framework-env.ts +105 -0
- package/src/index.ts +3 -0
package/CLAUDE.md
CHANGED
|
@@ -54,6 +54,7 @@ top-level `UltimateError` use in `error-codes.ts`.
|
|
|
54
54
|
| Concept | Owner | Note |
|
|
55
55
|
|---|---|---|
|
|
56
56
|
| which deploy this is | `environment.ts` (`ULTIMATE_ENV`) | the twin of `ROLE`; never a second env var |
|
|
57
|
+
| every env name the framework reads | `framework-env.ts` (`FRAMEWORK_ENV`) | a literal env read missing from it is red: `bun run scripts/framework-env.ts` (`X_FRAMEWORK_ENV_UNREGISTERED`) |
|
|
57
58
|
| one-home helpers | `store-mode` `html-escape` `cookie` `fnv1a` `pg-executor` `deprecation` `aws-sigv4` `der` | never copied (`X_HELPER_COPY`). Rows here: `docs/history/core.md` |
|
|
58
59
|
| an X.509 certificate's public key | `der.ts` (`x509Spki(der)`) | the ONE DER walk to the `subjectPublicKeyInfo` Web Crypto imports: auth's SAML key and mail's SNS key both read it; trailing bytes refused |
|
|
59
60
|
| the ONE keyed hash | `hmac.ts` (`hmac(alg, key, data, encoding?)`) | `bun run keyed-hasher` (`X_KEYED_HASHER`) † |
|
package/README.md
CHANGED
|
@@ -424,6 +424,16 @@ fallback of its own; the caller does.
|
|
|
424
424
|
is not our key. This is the twin of `roles.ts` — `ROLE` says what the process does,
|
|
425
425
|
`ULTIMATE_ENV` says which deploy it belongs to.
|
|
426
426
|
|
|
427
|
+
`FRAMEWORK_ENV` lists every environment name the framework itself reads, each with its owning
|
|
428
|
+
package and its `use`: `contract` (the deploy contract an app sets and may declare — `DATABASE_URL`,
|
|
429
|
+
`PORT`, and every adapter setting or credential: `S3_BUCKET`, `SMTP_URL`, `CLOUDFLARE_API_TOKEN`),
|
|
430
|
+
`switch` (present, it turns on a behaviour no app configures by that name — the `OTEL_*` family),
|
|
431
|
+
`internal` (the framework's own, every `ULTIMATE_*` included) or `host` (`HOME`, `CI`).
|
|
432
|
+
`frameworkEnvEntry(name)` answers the exact name first, then the longest registered prefix.
|
|
433
|
+
`x doctor` reports an app's own declared or sealed name on a `switch` or `internal` one
|
|
434
|
+
(`X_ENV_NAME_RESERVED`); `bun run scripts/framework-env.ts` holds the list complete against every
|
|
435
|
+
literal env read in shipped source.
|
|
436
|
+
|
|
427
437
|
`storeMode(Bun.env)` is the one answer to "memory store or database store?" for a seam with both —
|
|
428
438
|
`memory` under `test` (no database client is installed there), `database` everywhere else, `x dev`'s
|
|
429
439
|
embedded PGlite included. Never a `DATABASE_URL` truthiness check: `x dev` sets none.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ultimat3/core",
|
|
3
|
-
"version": "31.
|
|
3
|
+
"version": "31.17.0",
|
|
4
4
|
"description": "Ultimate's foundation: errors, context, env, config, clock, ids, logging, telemetry, lifecycle",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ultimate",
|
|
@@ -54,6 +54,6 @@
|
|
|
54
54
|
"test": "bun test"
|
|
55
55
|
},
|
|
56
56
|
"dependencies": {
|
|
57
|
-
"@ultimat3/schema": "31.
|
|
57
|
+
"@ultimat3/schema": "31.17.0"
|
|
58
58
|
}
|
|
59
59
|
}
|
package/src/config-keys.ts
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// at any depth and in any layer, is refused by path with the key it most likely meant. A key that
|
|
3
3
|
// is merged and read by nothing is the switch with no wire, and a typo (`drian`) is the same defect.
|
|
4
4
|
|
|
5
|
-
import type { JobsConfig } from './config';
|
|
5
|
+
import type { DatabaseConfig, JobsConfig } from './config';
|
|
6
6
|
import type { AssetsRetainConfig } from './config-assets';
|
|
7
7
|
import { BASE_FIX } from './config-fixes';
|
|
8
8
|
import type { MailRetainMimeConfig } from './config-mail';
|
|
@@ -64,6 +64,7 @@ export const SECTION_KEYS: Readonly<Record<string, readonly string[]>> = Object.
|
|
|
64
64
|
'pwa.screenshots[]': keysOf<PwaScreenshot>()(['src', 'sizes', 'type', 'formFactor', 'label']),
|
|
65
65
|
'mail.retainMime': keysOf<MailRetainMimeConfig>()(['maxBytes']),
|
|
66
66
|
'assets.retain': keysOf<AssetsRetainConfig>()(['disk', 'builds']),
|
|
67
|
+
database: keysOf<DatabaseConfig>()(['driver', 'ssl', 'rowSecurity', 'slowStatementMs']),
|
|
67
68
|
jobs: keysOf<JobsConfig>()([
|
|
68
69
|
'queues',
|
|
69
70
|
'concurrency',
|
package/src/config.ts
CHANGED
|
@@ -114,6 +114,11 @@ export interface DatabaseConfig {
|
|
|
114
114
|
* (`X_DB_ROW_SECURITY_BYPASSED`). Off by default: a transaction per bare statement is not free.
|
|
115
115
|
*/
|
|
116
116
|
readonly rowSecurity: boolean;
|
|
117
|
+
/**
|
|
118
|
+
* A statement at or over this many ms writes one `db.statement.slow` warn line in production.
|
|
119
|
+
* Unset is the boot's own 500 ms (`SLOW_STATEMENT_THRESHOLD_MS`); `0` is off.
|
|
120
|
+
*/
|
|
121
|
+
readonly slowStatementMs?: number;
|
|
117
122
|
}
|
|
118
123
|
|
|
119
124
|
/**
|
|
@@ -307,6 +312,9 @@ function validate(config: AppConfig): void {
|
|
|
307
312
|
oneOfIssue('database.driver', config.database.driver, DATABASE_DRIVERS),
|
|
308
313
|
booleanIssue('database.ssl', config.database.ssl),
|
|
309
314
|
booleanIssue('database.rowSecurity', config.database.rowSecurity),
|
|
315
|
+
config.database.slowStatementMs === undefined
|
|
316
|
+
? undefined
|
|
317
|
+
: countIssue('database.slowStatementMs', config.database.slowStatementMs, 0),
|
|
310
318
|
oneOfIssue('theme.defaultMode', config.theme.defaultMode, THEME_MODES),
|
|
311
319
|
// `null` is the documented "no redirect"; a path that is said must be one a browser can follow.
|
|
312
320
|
config.auth.signInPath === null
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
// Single responsibility: every environment variable name the framework itself reads, and which
|
|
2
|
+
// package reads it — the one list `x doctor` judges an app's own names against. Held complete by
|
|
3
|
+
// `scripts/framework-env.ts`: a literal env read in `packages/*/src` that is not here is red.
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* What reading the name means for an app that also uses it.
|
|
7
|
+
* - `contract`: the deploy contract — an app sets it, and may declare it in its `envSchema`: every
|
|
8
|
+
* adapter setting and credential (object storage, mail, a CDN, replication) is one, because
|
|
9
|
+
* declaring it IS how an app configures that adapter, and renaming it switches the adapter off.
|
|
10
|
+
* - `switch`: present, it turns a framework behaviour on that no app configures by that name (the
|
|
11
|
+
* OpenTelemetry signal family). An app holding it for its own purpose turns that on by accident.
|
|
12
|
+
* - `internal`: the framework sets it for itself, or reads it only in a gate or a test harness.
|
|
13
|
+
* - `host`: the platform's (`HOME`, `CI`); read, never owned.
|
|
14
|
+
*/
|
|
15
|
+
export type FrameworkEnvUse = 'contract' | 'switch' | 'internal' | 'host';
|
|
16
|
+
|
|
17
|
+
export interface FrameworkEnvName {
|
|
18
|
+
/** The exact name, or — with `prefix` — the head every name the framework reads under it shares. */
|
|
19
|
+
readonly name: string;
|
|
20
|
+
readonly prefix?: true;
|
|
21
|
+
/** The package that reads it, unscoped (`cache` is `@ultimat3/cache`). */
|
|
22
|
+
readonly owner: string;
|
|
23
|
+
readonly use: FrameworkEnvUse;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
const contract = (owner: string, ...names: string[]): FrameworkEnvName[] =>
|
|
27
|
+
names.map((name) => ({ name, owner, use: 'contract' }));
|
|
28
|
+
const toggles = (owner: string, ...names: string[]): FrameworkEnvName[] =>
|
|
29
|
+
names.map((name) => ({ name, owner, use: 'switch' }));
|
|
30
|
+
const internal = (owner: string, ...names: string[]): FrameworkEnvName[] =>
|
|
31
|
+
names.map((name) => ({ name, owner, use: 'internal' }));
|
|
32
|
+
const host = (owner: string, ...names: string[]): FrameworkEnvName[] =>
|
|
33
|
+
names.map((name) => ({ name, owner, use: 'host' }));
|
|
34
|
+
const prefix = (name: string, owner: string, use: FrameworkEnvUse): FrameworkEnvName => ({
|
|
35
|
+
name,
|
|
36
|
+
prefix: true,
|
|
37
|
+
owner,
|
|
38
|
+
use,
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Grouped by owner. Built from a grep of `packages/*\/src` (2026-11-12) plus the names the
|
|
43
|
+
* framework reads through a constant (`CURSOR_SECRET_KEY`), which no literal scan can see.
|
|
44
|
+
*/
|
|
45
|
+
export const FRAMEWORK_ENV: readonly FrameworkEnvName[] = [
|
|
46
|
+
...contract('ai', 'ANTHROPIC_API_KEY', 'OPENAI_API_KEY', 'EMBEDDINGS_API_KEY'),
|
|
47
|
+
...internal('ai', 'ULTIMATE_EVAL_RECORD'),
|
|
48
|
+
...contract('auth', 'SESSION_SECRET'),
|
|
49
|
+
...contract('auth', 'GITHUB_CLIENT_ID', 'GITHUB_CLIENT_SECRET'),
|
|
50
|
+
...contract('auth', 'GOOGLE_CLIENT_ID', 'GOOGLE_CLIENT_SECRET'),
|
|
51
|
+
...contract('cache', 'CLOUDFLARE_API_TOKEN', 'CLOUDFLARE_ZONE_ID'),
|
|
52
|
+
...contract('cache', 'FASTLY_API_TOKEN', 'FASTLY_SERVICE_ID'),
|
|
53
|
+
...contract('cli', 'APP_URL', 'SITE_ORIGIN', 'SYNC_URL', 'HOST', 'PORT', 'METRICS_PORT'),
|
|
54
|
+
...contract('cli', 'NODE_ENV', 'TRUSTED_PROXY_HOPS', 'WORKER_QUEUES', 'SENTRY_DSN'),
|
|
55
|
+
...contract('cli', 'S3_ENDPOINT', 'S3_BUCKET', 'S3_REGION', 'S3_FORCE_PATH_STYLE'),
|
|
56
|
+
...contract('cli', 'SCRAPE_CDP_URL'),
|
|
57
|
+
...toggles('cli', 'OTEL_SDK_DISABLED'),
|
|
58
|
+
...internal('cli', 'ULTIMATE_SEED_TIER', 'ULTIMATE_STATE_DIR', 'ULTIMATE_BUILD_CAPTURE'),
|
|
59
|
+
...internal('cli', 'ULTIMATE_DEV_CHILD', 'ULTIMATE_DEV_SUPERVISOR_PID', 'X_ENV'),
|
|
60
|
+
...internal('cli', 'ULTIMATE_KEEP_GLOBAL_CLI', 'ULTIMATE_VERIFY_STEP', 'CI_RUNNER'),
|
|
61
|
+
...host('cli', 'CI', 'GITHUB_SHA', 'GITHUB_BASE_REF', 'EDITOR', 'VISUAL'),
|
|
62
|
+
...contract('core', 'ULTIMATE_ENV', 'ROLE', 'BUILD_ID', 'APP_VERSION', 'LOG_LEVEL'),
|
|
63
|
+
...contract('core', 'ULTIMATE_CURSOR_SECRET', 'ULTIMATE_SECRETS_KEY'),
|
|
64
|
+
...contract('core', 'ULTIMATE_SECRETS_RETIRED_KEYS', 'METRICS_INTERVAL_MS'),
|
|
65
|
+
...contract('core', 'REDIS_URL', 'VALKEY_URL'),
|
|
66
|
+
...contract('core', 'OTEL_EXPORTER_OTLP_ENDPOINT', 'OTEL_EXPORTER_OTLP_HEADERS'),
|
|
67
|
+
...contract('core', 'OTEL_EXPORTER_OTLP_PROTOCOL', 'OTEL_TRACES_SAMPLER'),
|
|
68
|
+
...contract('core', 'OTEL_TRACES_SAMPLER_ARG'),
|
|
69
|
+
// The signal-specific family (`OTEL_TRACES_EXPORTER`, `OTEL_EXPORTER_OTLP_LOGS_ENDPOINT`).
|
|
70
|
+
prefix('OTEL_', 'core', 'switch'),
|
|
71
|
+
...host('core', 'USERNAME', 'USERDOMAIN'),
|
|
72
|
+
...contract('db', 'DATABASE_URL', 'DATABASE_POOL_MAX', 'DATABASE_POOLER'),
|
|
73
|
+
...contract('db', 'DATABASE_REPLICA_URL', 'DB_RETRY'),
|
|
74
|
+
...internal('db', 'ROLLBACK_ALLOW_DESTRUCTIVE'),
|
|
75
|
+
...host('jobs', 'HOSTNAME'),
|
|
76
|
+
...contract('mail', 'MAIL_FROM', 'MAIL_POOL_SIZE'),
|
|
77
|
+
...contract('mail', 'RESEND_API_KEY', 'RESEND_WEBHOOK_SECRET', 'SMTP_URL'),
|
|
78
|
+
...contract('mail', 'SES_ACCESS_KEY_ID', 'SES_SECRET_ACCESS_KEY', 'SES_SESSION_TOKEN'),
|
|
79
|
+
...contract('mail', 'SES_REGION', 'SES_ENDPOINT', 'SES_CONFIGURATION_SET'),
|
|
80
|
+
...contract('notify', 'ULTIMATE_APNS_PRIVATE_KEY', 'ULTIMATE_FCM_PRIVATE_KEY'),
|
|
81
|
+
...contract('pwa', 'ULTIMATE_VAPID_PUBLIC_KEY', 'ULTIMATE_VAPID_PRIVATE_KEY'),
|
|
82
|
+
...contract('realtime', 'NATS_URL', 'NATS_KV_BUCKET'),
|
|
83
|
+
...contract('realtime', 'REPLICATION_URL', 'REPLICATION_SLOT', 'REPLICATION_PUBLICATION'),
|
|
84
|
+
...contract('scraping', 'CHROME_PATH', 'PUPPETEER_EXECUTABLE_PATH'),
|
|
85
|
+
...host('scraping', 'HOME', 'TMPDIR', 'LOCALAPPDATA'),
|
|
86
|
+
...contract('storage', 'STORAGE_SIGNING_SECRET'),
|
|
87
|
+
...contract('storage', 'S3_ACCESS_KEY_ID', 'S3_SECRET_ACCESS_KEY', 'S3_SESSION_TOKEN'),
|
|
88
|
+
...contract('storage', 'AWS_ENDPOINT', 'AWS_REGION', 'AWS_SESSION_TOKEN'),
|
|
89
|
+
...internal('testing', 'TEST_DATABASE_URL', 'TEST_NATS_URL', 'TEST_REDIS_URL', 'TZ'),
|
|
90
|
+
...internal('testing', 'ULTIMATE_TEST_ALLOW_NET', 'ULTIMATE_TEST_NOW', 'ULTIMATE_TEST_SEED'),
|
|
91
|
+
...internal('testing', 'ULTIMATE_TEST_SLOT_HELD', 'ULTIMATE_TEST_ISOLATED'),
|
|
92
|
+
...internal('testing', 'ULTIMATE_CASSETTE', 'ULTIMATE_JOB_SIM_SEED'),
|
|
93
|
+
// Every `ULTIMATE_*` is the framework's: a name under it an app invents may be read tomorrow.
|
|
94
|
+
prefix('ULTIMATE_', 'core', 'internal'),
|
|
95
|
+
];
|
|
96
|
+
|
|
97
|
+
const EXACT = new Map<string, FrameworkEnvName>();
|
|
98
|
+
for (const entry of FRAMEWORK_ENV) if (entry.prefix !== true) EXACT.set(entry.name, entry);
|
|
99
|
+
const PREFIXES = FRAMEWORK_ENV.filter((entry) => entry.prefix === true).sort(
|
|
100
|
+
(a, b) => b.name.length - a.name.length,
|
|
101
|
+
);
|
|
102
|
+
|
|
103
|
+
/** The framework's entry for `name` — the exact name first, else the longest prefix it falls under. */
|
|
104
|
+
export const frameworkEnvEntry = (name: string): FrameworkEnvName | undefined =>
|
|
105
|
+
EXACT.get(name) ?? PREFIXES.find((entry) => name.startsWith(entry.name));
|
package/src/index.ts
CHANGED
|
@@ -690,6 +690,9 @@ export type {
|
|
|
690
690
|
export { flightGate, gateOverloaded } from './flight-gate';
|
|
691
691
|
export { fnv1a } from './fnv1a';
|
|
692
692
|
export { formatBytes } from './format-bytes';
|
|
693
|
+
// Every environment name the framework reads, and its owner: what `x doctor` judges an app's against.
|
|
694
|
+
export type { FrameworkEnvName, FrameworkEnvUse } from './framework-env';
|
|
695
|
+
export { FRAMEWORK_ENV, frameworkEnvEntry } from './framework-env';
|
|
693
696
|
export type { GateRateLimit, RateLimitSubject } from './gate-shapes';
|
|
694
697
|
export {
|
|
695
698
|
AUDIT_SINK_FAILED_EVENT,
|