The model says what runs and what is kept, in which environment and at which locations. It never
names a platform, a product, a size or a secret store. Those are settings, and they live in
their own file, .metaobjects/settings.json, beside config.json (ADR-0070, calls 5 and 13).
TypeScript only, and experimental. Only TypeScript reads the settings file, so no other port's
config reader changes and config.json gains no keys. The reader and the resolver ship in
@metaobjectsdev/sdk in 1.4.0; no generator reads them yet, and the file's shape may change in a
minor release while the systems work lands. A project with no settings file has no settings,
and nothing changes for it.
{
"extends": "../estate/settings.json",
"targets": {
"lab": { "platform": "docker", "host": "lab-01.example", "country": "NL" }
},
"platforms": {
"docker": { "emitter": "compose" }
},
"resourceDefaults": {
"docker": { "rdb": { "product": "postgres", "version": "18" } }
},
"purposes": {
"production": { "replicas": 2, "rdb": { "backupDays": 35 } }
},
"environments": {
"Production": {
"apps": { "shop::Shop.api": { "replicas": 4 } },
"provisions": { "shop-db": { "backupDays": 14 } }
}
},
"secrets": {
"stores": { "vault": { "product": "openbao", "address": "https://bao.example" } },
"generated": { "docker": "vault" },
"adopted": "vault"
}
}| Block | Says | Keyed by |
|---|---|---|
extends |
Another settings file this one builds on: a path relative to this file, or a package specifier | |
targets |
The places things can be put: a platform, a country, the platform's region and zones, and the platform's own identifiers (account, project, host) |
A name you choose |
platforms |
For each platform, its emitter, and how it runs apps, schedules jobs and routes traffic |
Platform |
resourceDefaults |
The product and version for each kind of resource |
Platform, then resource kind |
purposes |
Sizes and counts for every environment of that purpose: plain values for apps, a block per resource kind | production, staging, test, development |
environments |
What differs in one environment: an app's size or tag (apps), a provision's size (provisions), public hosts, and API addresses |
Environment, then node name |
secrets |
The stores; which one keeps generated credentials for each platform (generated) or for one target (targets); which keeps adopted keys (adopted) |
placement (which target a location means) and fileTransports are accepted so a complete
settings file loads, and are read by later 1.4.0 changes. Any other top-level key is an error.
A settings file may extend a shared estate file, which may extend another. The files merge key
by key and the nearer file wins, so a fleet-wide upgrade from Postgres 18 to 19 is one line in the
shared file. Arrays replace rather than append. Each file may leave out what the file it extends
supplies; the merged result must be complete. extends takes a path relative to the file, or a
package specifier: an estate's shared settings usually live in another repository, and a published
package is how a project reaches them, as with tsconfig's extends.
On top of the merged file, one value for one node comes from these layers, lowest first:
| Layer | From |
|---|---|
generator |
The default the generator passes in |
resourceDefaults |
resourceDefaults.<platform>.<kind>, for a resource |
purpose |
purposes.<purpose>: its plain values for an app, its <kind> block for a resource |
environment |
environments.<environment>.apps.<app> or .provisions.<provision> |
Every resolved value carries its layer, the key path it was read from, and the file that wrote it, so a generated file can say where each number came from.
import { loadSettings, resolveResource, resolveGeneratedStore } from "@metaobjectsdev/sdk";
const settings = await loadSettings(".metaobjects");
if (settings) {
const db = resolveResource(settings, {
kind: "rdb",
target: "lab",
environment: { name: "Production", purpose: "production" },
provision: "shop-db",
generatorDefaults: { product: "postgres", version: "18" },
});
db.values.get("backupDays"); // { value: 14, layer: "environment", path: [...], file: ".../settings.json" }
resolveGeneratedStore(settings, "lab")?.name; // "vault"
}The resolver is told the target by name. Choosing it from a location is placement's job, and
arrives with it.
| Code | When |
|---|---|
ERR_SETTINGS_INVALID |
A file is not JSON, has a key the format does not know, a purpose outside the four, or a nested value where a plain one belongs; or the merged settings miss a required key |
ERR_SETTINGS_EXTENDS_NOT_FOUND |
extends names a file or package that cannot be found |
ERR_SETTINGS_EXTENDS_CYCLE |
Settings files extend each other in a cycle |
ERR_SETTINGS_UNKNOWN_PLATFORM |
A target, a resourceDefaults key or a secrets.generated key names a platform platforms does not declare |
ERR_SETTINGS_UNKNOWN_STORE |
secrets names a store secrets.stores does not declare |
ERR_SETTINGS_UNKNOWN_TARGET |
secrets.targets names, or a resolver is asked for, a target targets does not declare |
These are settings errors, raised by the TypeScript reader, and not loader codes. Checks that read
the model and the settings together (a key that names no node, a location with no target) are
meta verify rules and arrive with the vocabulary they read.