@happyvertical/smrt-config 0.60.14 → 0.60.16
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/AGENTS.md +43 -0
- package/README.md +39 -0
- package/dist/browser.js +2 -2
- package/dist/chunks/{shared-D9LcDpJo.js → shared-BY0fqhKU.js} +2 -2
- package/dist/chunks/{shared-D9LcDpJo.js.map → shared-BY0fqhKU.js.map} +1 -1
- package/dist/deployment/chart-values.d.ts +120 -0
- package/dist/deployment/chart-values.d.ts.map +1 -0
- package/dist/deployment/compose-contract.d.ts +141 -0
- package/dist/deployment/compose-contract.d.ts.map +1 -0
- package/dist/deployment.d.ts +11 -0
- package/dist/deployment.d.ts.map +1 -0
- package/dist/deployment.js +720 -0
- package/dist/deployment.js.map +1 -0
- package/dist/export.d.ts +7 -0
- package/dist/export.d.ts.map +1 -1
- package/dist/index.js +2 -2
- package/dist/shared.d.ts +1 -1
- package/dist/shared.d.ts.map +1 -1
- package/dist/smrt-knowledge.okf.md +4 -2
- package/package.json +10 -3
- package/schemas/x-happyvertical.v1.schema.json +200 -0
package/AGENTS.md
CHANGED
|
@@ -27,6 +27,49 @@ Configuration management with cosmiconfig, secret sanitization, and SSG export.
|
|
|
27
27
|
| `getApplicationRuntimePreset(profile)` | Inspect a profile's safe provider defaults |
|
|
28
28
|
| `resolveCliDatabaseConfig(env?)` | CLI database precedence shared by `smrt` and `smrt-dev-mcp`: declared `packages.cli.database.url` > `DATABASE_URL` (engine: config type > `DATABASE_TYPE` > scheme); read-only (`src/database-environment.ts`) |
|
|
29
29
|
|
|
30
|
+
## Compose deployment contract (`./deployment`, #4789)
|
|
31
|
+
|
|
32
|
+
`@happyvertical/smrt-config/deployment` is a separate entry, not part of the
|
|
33
|
+
root export: the `x-happyvertical` contract (version 1) that makes a Compose
|
|
34
|
+
file an application's deployment declaration. Guide:
|
|
35
|
+
`docs/content/deployment-compose.md`.
|
|
36
|
+
|
|
37
|
+
- `schemas/x-happyvertical.v1.schema.json` is the published JSON Schema
|
|
38
|
+
(`exports['./schemas/*']`, shipped through `files`). Other repositories
|
|
39
|
+
vendor it: keep it free of regex lookarounds (RE2 consumers) and clean under
|
|
40
|
+
Ajv strict mode. `src/deployment/schema.test.ts` holds its version, presets,
|
|
41
|
+
roles and bindings equal to the constants in `compose-contract.ts` and proves
|
|
42
|
+
every annotation shape error is refused by both.
|
|
43
|
+
- `src/deployment/compose-contract.ts`: `validateComposeDeployment()` (stages
|
|
44
|
+
`declare` and `deploy`), the resolved declaration, and the plain-text
|
|
45
|
+
report. Pure and browser-safe: the caller parses YAML. Every rule has an
|
|
46
|
+
issue code and a test in `compose-contract.test.ts`; messages are for
|
|
47
|
+
non-experts and always carry a `fix`. The document is untrusted: the
|
|
48
|
+
validator must never throw (format values with `describe()`, never
|
|
49
|
+
`String()`/`JSON.stringify()`), fails closed on spellings it cannot tell
|
|
50
|
+
apart, refuses a `<<` key anywhere (the caller parsed without merge keys),
|
|
51
|
+
and refuses `$` in what a platform would run or mount (`command`,
|
|
52
|
+
`entrypoint`, `migrate.command`, `health`, volume targets), because Compose
|
|
53
|
+
interpolates the whole file; `name` and a declare-stage `image` are carried
|
|
54
|
+
only when literal. The schema carries the same `$` patterns.
|
|
55
|
+
- `entrypoint`/`command` keep Compose meaning in the declaration: absent =
|
|
56
|
+
the image's own runs; `[]` (or '') = discarded. Never collapse the two.
|
|
57
|
+
- `src/deployment/chart-values.ts`: `renderSmrtAppChartValues()` renders a
|
|
58
|
+
`deploy`-stage declaration plus environment-owned inputs into `smrt-app`
|
|
59
|
+
chart values. It invents no defaults for Secrets, resources or ingress,
|
|
60
|
+
validates the inputs (hand-written JSON), renders `target` only (`current`
|
|
61
|
+
is passed through, never synthesized), and requires an explicit
|
|
62
|
+
`entrypoint` because the chart's `command` replaces the image's.
|
|
63
|
+
- `charts/smrt-app/fixtures/starter.json` is generated from
|
|
64
|
+
`packages/template-sveltekit/template/compose.yaml` by
|
|
65
|
+
`scripts/compose-contract-fixture.mjs --write`; `scripts/compose-contract.test.mjs`
|
|
66
|
+
fails on drift. Change the contract, the template annotations and the
|
|
67
|
+
fixture together.
|
|
68
|
+
- Version 1 changes by addition only (new binding kind, preset or optional
|
|
69
|
+
field). Changing the meaning of a field is a new `v2` schema file and a new
|
|
70
|
+
version constant, never an edit to v1.
|
|
71
|
+
- Environment values are deliberately not part of the declaration.
|
|
72
|
+
|
|
30
73
|
## Key Files
|
|
31
74
|
|
|
32
75
|
- `src/index.ts` — Node entry: `src/shared.ts` plus `loadConfig()`; `src/browser.ts` — `exports['.'].browser` entry, same surface with a `loadConfig()` that rejects (model roots bundle for browsers, #3625)
|
package/README.md
CHANGED
|
@@ -114,6 +114,45 @@ not a runtime block (`null`, `false`, `0`, `''`) throws the same
|
|
|
114
114
|
`RuntimeProfileValidationError` instead of selecting `local`; `setConfig()`
|
|
115
115
|
rejects such a `runtime` override with that error before storing anything.
|
|
116
116
|
|
|
117
|
+
### Compose deployment contract
|
|
118
|
+
|
|
119
|
+
`@happyvertical/smrt-config/deployment` reads an application's Compose file as
|
|
120
|
+
its deployment declaration. The file carries `x-happyvertical` extension fields
|
|
121
|
+
(contract version 1): a top-level block with `preset`, `domain` and `migrate`,
|
|
122
|
+
`role: web|worker` with a `health` check on the services the application runs,
|
|
123
|
+
and `binding: postgres|bucket|email|ai` on local stand-ins for platform
|
|
124
|
+
services. See the
|
|
125
|
+
[compose deployment contract](https://github.com/happyvertical/smrt/blob/main/docs/content/deployment-compose.md)
|
|
126
|
+
for the fields and the supported platform subset.
|
|
127
|
+
|
|
128
|
+
```typescript
|
|
129
|
+
import { parse } from 'yaml';
|
|
130
|
+
import {
|
|
131
|
+
formatComposeDeploymentReport,
|
|
132
|
+
renderSmrtAppChartValues,
|
|
133
|
+
validateComposeDeployment,
|
|
134
|
+
} from '@happyvertical/smrt-config/deployment';
|
|
135
|
+
|
|
136
|
+
// The entry does no I/O: parse the YAML yourself, with merge keys enabled.
|
|
137
|
+
const document = parse(composeText, { merge: true });
|
|
138
|
+
|
|
139
|
+
// `declare` checks the file as written; `deploy` also requires image digests.
|
|
140
|
+
const result = validateComposeDeployment(document, {
|
|
141
|
+
stage: 'deploy',
|
|
142
|
+
images: { web: webDigest, worker: workerDigest },
|
|
143
|
+
});
|
|
144
|
+
if (!result.ok) throw new Error(formatComposeDeploymentReport(result));
|
|
145
|
+
|
|
146
|
+
// Self-host rendering: values for the smrt-app chart.
|
|
147
|
+
const values = renderSmrtAppChartValues(result.declaration, inputs);
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
Each issue has a `code`, a `path` into the file, a plain-language `message`
|
|
151
|
+
and a `fix`. Unannotated services are reported as warnings: they run locally
|
|
152
|
+
and are never deployed. The JSON Schema for the annotations is published as
|
|
153
|
+
`@happyvertical/smrt-config/schemas/x-happyvertical.v1.schema.json`. From a
|
|
154
|
+
terminal, use `smrt deploy:check` and `smrt deploy:chart-values`.
|
|
155
|
+
|
|
117
156
|
### Use config in code
|
|
118
157
|
|
|
119
158
|
```typescript
|
package/dist/browser.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { A as
|
|
1
|
+
import { A as describeAIProviderConfig, C as RuntimeProfileValidationError, D as AI_PROVIDER_KEY_ENV, E as AIProviderNotConfiguredError, F as toAIClientOptions, I as tryResolveAIProviderConfig, L as withAIAliases, M as mergeAIConfigObjects, N as redactBaseUrl, O as DEFAULT_AI_ENV_PREFIXES, P as resolveAIProviderConfig, S as mergeConfigs, T as resolveApplicationRuntime, _ as parseExportedConfig, a as getModuleConfig, b as clearRuntimeConfig, c as mergeAIConfigLayers, d as resolveConfiguredApplicationRuntime, f as resolveEffectiveApplicationRuntime, g as mergeExportedConfig, h as exportConfig, i as getConfig, j as getDefaultAIKeyEnvName, k as canonicalizeAIConfig, l as resolveCliDatabaseConfig, m as tryResolveConfiguredAIProvider, n as defineConfig, o as getPackageConfig, p as setConfig, r as getAIConfigBlock, s as getSiteConfig, t as clearCache, u as resolveConfiguredAIProvider, v as redactValueSecrets, w as getApplicationRuntimePreset, x as getRuntimeConfig, y as sanitizeConfig } from "./chunks/shared-BY0fqhKU.js";
|
|
2
2
|
//#region src/browser.ts
|
|
3
3
|
async function loadConfig(_options) {
|
|
4
4
|
throw new Error("@happyvertical/smrt-config: loadConfig() reads smrt.config.* from the filesystem and is not available in a browser build. Provide configuration with setConfig() instead.");
|
|
5
5
|
}
|
|
6
6
|
//#endregion
|
|
7
|
-
export { AIProviderNotConfiguredError, AI_PROVIDER_KEY_ENV, DEFAULT_AI_ENV_PREFIXES, RuntimeProfileValidationError, canonicalizeAIConfig, clearCache, clearRuntimeConfig, defineConfig, describeAIProviderConfig, exportConfig, getAIConfigBlock, getApplicationRuntimePreset, getConfig, getDefaultAIKeyEnvName, getModuleConfig, getPackageConfig, getRuntimeConfig, getSiteConfig, loadConfig, mergeAIConfigLayers, mergeAIConfigObjects, mergeConfigs, mergeExportedConfig, parseExportedConfig, redactBaseUrl, resolveAIProviderConfig, resolveApplicationRuntime, resolveCliDatabaseConfig, resolveConfiguredAIProvider, resolveConfiguredApplicationRuntime, resolveEffectiveApplicationRuntime, sanitizeConfig, setConfig, toAIClientOptions, tryResolveAIProviderConfig, tryResolveConfiguredAIProvider, withAIAliases };
|
|
7
|
+
export { AIProviderNotConfiguredError, AI_PROVIDER_KEY_ENV, DEFAULT_AI_ENV_PREFIXES, RuntimeProfileValidationError, canonicalizeAIConfig, clearCache, clearRuntimeConfig, defineConfig, describeAIProviderConfig, exportConfig, getAIConfigBlock, getApplicationRuntimePreset, getConfig, getDefaultAIKeyEnvName, getModuleConfig, getPackageConfig, getRuntimeConfig, getSiteConfig, loadConfig, mergeAIConfigLayers, mergeAIConfigObjects, mergeConfigs, mergeExportedConfig, parseExportedConfig, redactBaseUrl, redactValueSecrets as redactSecretValues, resolveAIProviderConfig, resolveApplicationRuntime, resolveCliDatabaseConfig, resolveConfiguredAIProvider, resolveConfiguredApplicationRuntime, resolveEffectiveApplicationRuntime, sanitizeConfig, setConfig, toAIClientOptions, tryResolveAIProviderConfig, tryResolveConfiguredAIProvider, withAIAliases };
|
|
8
8
|
|
|
9
9
|
//# sourceMappingURL=browser.js.map
|
|
@@ -1065,6 +1065,6 @@ function tryResolveConfiguredAIProvider(options = {}) {
|
|
|
1065
1065
|
});
|
|
1066
1066
|
}
|
|
1067
1067
|
//#endregion
|
|
1068
|
-
export {
|
|
1068
|
+
export { describeAIProviderConfig as A, setCachedConfig as B, RuntimeProfileValidationError as C, AI_PROVIDER_KEY_ENV as D, AIProviderNotConfiguredError as E, toAIClientOptions as F, setLoadedConfig as H, tryResolveAIProviderConfig as I, withAIAliases as L, mergeAIConfigObjects as M, redactBaseUrl as N, DEFAULT_AI_ENV_PREFIXES as O, resolveAIProviderConfig as P, getCachedConfig as R, mergeConfigs as S, resolveApplicationRuntime as T, setExplorer as V, parseExportedConfig as _, getModuleConfig as a, clearRuntimeConfig as b, mergeAIConfigLayers as c, resolveConfiguredApplicationRuntime as d, resolveEffectiveApplicationRuntime as f, mergeExportedConfig as g, exportConfig as h, getConfig as i, getDefaultAIKeyEnvName as j, canonicalizeAIConfig as k, resolveCliDatabaseConfig as l, tryResolveConfiguredAIProvider as m, defineConfig as n, getPackageConfig as o, setConfig as p, getAIConfigBlock as r, getSiteConfig as s, clearCache as t, resolveConfiguredAIProvider as u, redactValueSecrets as v, getApplicationRuntimePreset as w, getRuntimeConfig as x, sanitizeConfig as y, getExplorer as z };
|
|
1069
1069
|
|
|
1070
|
-
//# sourceMappingURL=shared-
|
|
1070
|
+
//# sourceMappingURL=shared-BY0fqhKU.js.map
|