@antelopejs/interface-core 0.0.13 → 0.0.14
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/config.d.ts +16 -0
- package/dist/config.js.map +1 -1
- package/docs/7.configuration.md +44 -0
- package/package.json +1 -1
package/dist/config.d.ts
CHANGED
|
@@ -32,6 +32,22 @@ export interface ModuleSourceLocalFolder extends ModuleSource {
|
|
|
32
32
|
installCommand?: ModuleInstallCommand;
|
|
33
33
|
reloadCommand?: ModuleInstallCommand;
|
|
34
34
|
}
|
|
35
|
+
/**
|
|
36
|
+
* A value a module may publish as a config variable.
|
|
37
|
+
*
|
|
38
|
+
* Only primitives travel between modules: the value is substituted into
|
|
39
|
+
* another module's configuration before that module constructs.
|
|
40
|
+
*/
|
|
41
|
+
export type ConfigVarValue = string | number | boolean;
|
|
42
|
+
/**
|
|
43
|
+
* The config variables a module publishes from its `construct` callback.
|
|
44
|
+
*
|
|
45
|
+
* The keys must match the names the module declares in its `package.json`
|
|
46
|
+
* under `antelopeJs.configVars`. Consumers reference them from their own
|
|
47
|
+
* configuration with `${@<moduleName>.<VAR_NAME>}`, and the core substitutes
|
|
48
|
+
* the values before constructing the consumer.
|
|
49
|
+
*/
|
|
50
|
+
export type ConfigVars = Record<string, ConfigVarValue>;
|
|
35
51
|
export interface AntelopeTestConfig {
|
|
36
52
|
folder?: string;
|
|
37
53
|
setup?: () => undefined | Partial<AntelopeConfig> | Promise<undefined | Partial<AntelopeConfig>>;
|
package/dist/config.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":";AAAA,sBAAsB;;
|
|
1
|
+
{"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":";AAAA,sBAAsB;;AA2HtB,oCAEC;AAFD,SAAgB,YAAY,CAAC,KAAkB;IAC7C,OAAO,KAAK,CAAC;AACf,CAAC"}
|
package/docs/7.configuration.md
CHANGED
|
@@ -174,6 +174,50 @@ Logging configuration within the project config.
|
|
|
174
174
|
| `formatter` | `Record<string, string>` | Custom formatters per channel |
|
|
175
175
|
| `dateFormat` | `string` | Date format string for log timestamps |
|
|
176
176
|
|
|
177
|
+
## Config variables
|
|
178
|
+
|
|
179
|
+
A module can publish named values other modules reference from their own configuration. The provider declares the names it publishes in its `package.json`, returns them from `construct`, and the core substitutes them into every consumer before that consumer constructs.
|
|
180
|
+
|
|
181
|
+
```json
|
|
182
|
+
{
|
|
183
|
+
"name": "api",
|
|
184
|
+
"antelopeJs": {
|
|
185
|
+
"configVars": ["API_PORT"]
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
```
|
|
189
|
+
|
|
190
|
+
```ts
|
|
191
|
+
import type { ConfigVars } from "@antelopejs/interface-core/config";
|
|
192
|
+
|
|
193
|
+
export async function construct(config: unknown): Promise<ConfigVars> {
|
|
194
|
+
const port = await bindPort(config);
|
|
195
|
+
return { API_PORT: port };
|
|
196
|
+
}
|
|
197
|
+
```
|
|
198
|
+
|
|
199
|
+
A consumer references the value with `${@<moduleName>.<VAR_NAME>}`, where `<moduleName>` is the module key used in the project configuration:
|
|
200
|
+
|
|
201
|
+
```ts
|
|
202
|
+
export default defineConfig({
|
|
203
|
+
name: "my-project",
|
|
204
|
+
modules: {
|
|
205
|
+
api: { version: "1.0.0" },
|
|
206
|
+
dms: {
|
|
207
|
+
version: "1.0.0",
|
|
208
|
+
config: { apiBaseUrl: "http://127.0.0.1:${@api.API_PORT}" },
|
|
209
|
+
},
|
|
210
|
+
},
|
|
211
|
+
});
|
|
212
|
+
```
|
|
213
|
+
|
|
214
|
+
| Type | Definition | Description |
|
|
215
|
+
| ---------------- | -------------------------------- | --------------------------------------------------- |
|
|
216
|
+
| `ConfigVarValue` | `string \| number \| boolean` | A single published value |
|
|
217
|
+
| `ConfigVars` | `Record<string, ConfigVarValue>` | The record `construct` returns to publish variables |
|
|
218
|
+
|
|
219
|
+
Values are resolved once, at construct time, and never re-resolved afterwards. See the core documentation for the resolution order and the failure modes.
|
|
220
|
+
|
|
177
221
|
## `AntelopeTestConfig`
|
|
178
222
|
|
|
179
223
|
Test configuration for the project.
|