@antelopejs/interface-core 0.0.14 → 0.1.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/dist/config.d.ts CHANGED
@@ -40,14 +40,25 @@ export interface ModuleSourceLocalFolder extends ModuleSource {
40
40
  */
41
41
  export type ConfigVarValue = string | number | boolean;
42
42
  /**
43
- * The config variables a module publishes from its `construct` callback.
43
+ * The config variables a module publishes from its `provide` callback.
44
44
  *
45
45
  * The keys must match the names the module declares in its `package.json`
46
46
  * under `antelopeJs.configVars`. Consumers reference them from their own
47
47
  * configuration with `${@<moduleName>.<VAR_NAME>}`, and the core substitutes
48
- * the values before constructing the consumer.
48
+ * the values before any module constructs.
49
49
  */
50
50
  export type ConfigVars = Record<string, ConfigVarValue>;
51
+ /**
52
+ * The `provide` lifecycle callback a provider module exports.
53
+ *
54
+ * It runs before every `construct`, which is what makes the published values
55
+ * available to consumers whatever the order of the interface graph. A provider
56
+ * must therefore compute its values on its own: no other module has
57
+ * constructed yet, so awaiting another module's interface from `provide`
58
+ * deadlocks the startup. The core interfaces registered before the module
59
+ * lifecycle starts, `GetRuntimeInfo()` among them, remain available.
60
+ */
61
+ export type ConfigVarProvider = (config: unknown) => Promise<ConfigVars | void> | ConfigVars | void;
51
62
  export interface AntelopeTestConfig {
52
63
  folder?: string;
53
64
  setup?: () => undefined | Partial<AntelopeConfig> | Promise<undefined | Partial<AntelopeConfig>>;
@@ -1 +1 @@
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"}
1
+ {"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":";AAAA,sBAAsB;;AAyItB,oCAEC;AAFD,SAAgB,YAAY,CAAC,KAAkB;IAC7C,OAAO,KAAK,CAAC;AACf,CAAC"}
@@ -176,7 +176,7 @@ Logging configuration within the project config.
176
176
 
177
177
  ## Config variables
178
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.
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 its `provide` callback, and the core substitutes them into every consumer before any module constructs.
180
180
 
181
181
  ```json
182
182
  {
@@ -190,12 +190,14 @@ A module can publish named values other modules reference from their own configu
190
190
  ```ts
191
191
  import type { ConfigVars } from "@antelopejs/interface-core/config";
192
192
 
193
- export async function construct(config: unknown): Promise<ConfigVars> {
194
- const port = await bindPort(config);
193
+ export async function provide(config: unknown): Promise<ConfigVars> {
194
+ const port = await reservePort(config);
195
195
  return { API_PORT: port };
196
196
  }
197
197
  ```
198
198
 
199
+ `provide` is optional and only providers implement it. It runs before every `construct`, so a provider cannot await another module's interface from it: nothing has constructed yet. The core interfaces registered before the module lifecycle starts — `GetRuntimeInfo()` among them — stay available, which is enough to compute a port, a base URL or a generated secret.
200
+
199
201
  A consumer references the value with `${@<moduleName>.<VAR_NAME>}`, where `<moduleName>` is the module key used in the project configuration:
200
202
 
201
203
  ```ts
@@ -211,12 +213,13 @@ export default defineConfig({
211
213
  });
212
214
  ```
213
215
 
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 |
216
+ | Type | Definition | Description |
217
+ | ------------------- | ------------------------------------------------------------------------ | --------------------------------------- |
218
+ | `ConfigVarValue` | `string \| number \| boolean` | A single published value |
219
+ | `ConfigVars` | `Record<string, ConfigVarValue>` | The record `provide` returns |
220
+ | `ConfigVarProvider` | `(config: unknown) => Promise<ConfigVars \| void> \| ConfigVars \| void` | The signature of the `provide` callback |
218
221
 
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.
222
+ Values are resolved once, before construction, and never re-resolved afterwards. `construct` cannot publish config variables: its return value is ignored. See the core documentation for the resolution order and the failure modes.
220
223
 
221
224
  ## `AntelopeTestConfig`
222
225
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@antelopejs/interface-core",
3
- "version": "0.0.14",
3
+ "version": "0.1.0",
4
4
  "description": "AntelopeJS core interface primitives - proxies, decorators, interface functions, and logging",
5
5
  "keywords": [
6
6
  "antelopejs",