@ultimat3/core 31.14.0 → 31.16.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-islands.ts +21 -5
- 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.16.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.16.0"
|
|
58
58
|
}
|
|
59
59
|
}
|
package/src/config-islands.ts
CHANGED
|
@@ -17,9 +17,15 @@ import { describeValue } from './error-render';
|
|
|
17
17
|
* 55,585 → 42,331 B — the win route grouping now takes by default where islands co-render. Turn
|
|
18
18
|
* it on only where cross-page caching of shared code is worth it, and weigh the routes with
|
|
19
19
|
* `x verify`.
|
|
20
|
+
*
|
|
21
|
+
* `vendorSolid: true` builds Solid once, as `/islands/vendor-solid.<hash>.js`, and every island
|
|
22
|
+
* imports it instead of inlining its own copy. OFF BY DEFAULT, measured As of 2026-11-12 (Bun
|
|
23
|
+
* 1.4.4, solid-js 1.9.17): the vendor is 48,083 B (17,388 B gzip) where an island inlines a
|
|
24
|
+
* tree-shaken ~14 kB, so it pays only on a route rendering four or more Solid islands built apart.
|
|
20
25
|
*/
|
|
21
26
|
export interface IslandsConfig {
|
|
22
27
|
readonly sharedChunks: boolean;
|
|
28
|
+
readonly vendorSolid: boolean;
|
|
23
29
|
}
|
|
24
30
|
|
|
25
31
|
export interface IslandsSection {
|
|
@@ -27,24 +33,34 @@ export interface IslandsSection {
|
|
|
27
33
|
}
|
|
28
34
|
|
|
29
35
|
export interface IslandsSectionInput {
|
|
30
|
-
readonly islands?:
|
|
36
|
+
readonly islands?:
|
|
37
|
+
| {
|
|
38
|
+
readonly sharedChunks?: boolean | undefined;
|
|
39
|
+
readonly vendorSolid?: boolean | undefined;
|
|
40
|
+
}
|
|
41
|
+
| undefined;
|
|
31
42
|
}
|
|
32
43
|
|
|
33
44
|
/** The last layer that said it wins, as every scalar does. */
|
|
34
45
|
export function mergeIslands(layers: readonly IslandsSectionInput[]): IslandsSection {
|
|
35
46
|
let sharedChunks = false;
|
|
47
|
+
let vendorSolid = false;
|
|
36
48
|
for (const layer of layers) {
|
|
37
49
|
const said = layer.islands?.sharedChunks;
|
|
38
50
|
if (said !== undefined) sharedChunks = said;
|
|
51
|
+
const vendor = layer.islands?.vendorSolid;
|
|
52
|
+
if (vendor !== undefined) vendorSolid = vendor;
|
|
39
53
|
}
|
|
40
|
-
return { islands: { sharedChunks } };
|
|
54
|
+
return { islands: { sharedChunks, vendorSolid } };
|
|
41
55
|
}
|
|
42
56
|
|
|
43
57
|
/** Appends every refusal the section earns to `issues`, `config.ts`' one list. */
|
|
44
58
|
export function islandsIssues(config: IslandsSection, issues: string[]): void {
|
|
45
59
|
// `unknown`: an untyped config file reaches this validator with whatever it wrote.
|
|
46
|
-
const
|
|
47
|
-
|
|
48
|
-
|
|
60
|
+
for (const key of ['sharedChunks', 'vendorSolid'] as const) {
|
|
61
|
+
const said: unknown = config.islands[key];
|
|
62
|
+
if (typeof said !== 'boolean') {
|
|
63
|
+
issues.push(`islands.${key} must be true or false, not ${describeValue(said)}`);
|
|
64
|
+
}
|
|
49
65
|
}
|
|
50
66
|
}
|
|
@@ -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,
|