@antelopejs/interface-core 0.2.0 → 0.2.1
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 +12 -0
- package/dist/config.js.map +1 -1
- package/dist/modules.d.ts +40 -0
- package/dist/modules.js +30 -1
- package/dist/modules.js.map +1 -1
- package/docs/5.modules.md +31 -0
- package/docs/7.configuration.md +10 -8
- package/package.json +2 -2
package/dist/config.d.ts
CHANGED
|
@@ -98,6 +98,18 @@ export interface AntelopeModuleConfig {
|
|
|
98
98
|
* priority 0.
|
|
99
99
|
*/
|
|
100
100
|
exportPriority?: Record<string, number>;
|
|
101
|
+
/**
|
|
102
|
+
* Keeps the module declared, with its configuration, without loading it.
|
|
103
|
+
* A disabled module is left out of the project as if it were not listed.
|
|
104
|
+
*/
|
|
105
|
+
disabled?: boolean;
|
|
106
|
+
/**
|
|
107
|
+
* Lets the project start without this module. An optional module is
|
|
108
|
+
* loaded once the others have started; when it fails to download,
|
|
109
|
+
* construct or start, the failure is logged and the project runs on
|
|
110
|
+
* without it.
|
|
111
|
+
*/
|
|
112
|
+
optional?: boolean;
|
|
101
113
|
}
|
|
102
114
|
export interface AntelopeLogging {
|
|
103
115
|
enabled?: boolean;
|
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;;AAmKtB,oCAEC;AAFD,SAAgB,YAAY,CAAC,KAAkB;IAC7C,OAAO,KAAK,CAAC;AACf,CAAC"}
|
package/dist/modules.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { AntelopeModuleConfig } from "./config";
|
|
1
2
|
import { EventProxy } from "./proxies";
|
|
2
3
|
import { type ModuleExecutionContext } from "./internal";
|
|
3
4
|
/** Runs work with module ownership and an optional provider route across awaits. */
|
|
@@ -176,3 +177,42 @@ export declare const DestroyModule: (module: string) => Promise<void>;
|
|
|
176
177
|
* @throws Error if the module cannot be reloaded
|
|
177
178
|
*/
|
|
178
179
|
export declare const ReloadModule: (module: string) => Promise<void>;
|
|
180
|
+
/**
|
|
181
|
+
* A module as the project's configuration file declares it, under its key in
|
|
182
|
+
* `modules`, with the shorthand forms expanded.
|
|
183
|
+
*/
|
|
184
|
+
export type ModuleDeclaration = Pick<AntelopeModuleConfig, "source" | "config" | "disabled" | "optional">;
|
|
185
|
+
/**
|
|
186
|
+
* The fields of a module's declaration to write. A field left out keeps what
|
|
187
|
+
* the file already holds.
|
|
188
|
+
*/
|
|
189
|
+
export type ModuleDeclarationChanges = Partial<ModuleDeclaration>;
|
|
190
|
+
/**
|
|
191
|
+
* List the modules the project's configuration file declares, by key,
|
|
192
|
+
* disabled ones included.
|
|
193
|
+
*
|
|
194
|
+
* @returns The declarations of the top-level `modules` of the file
|
|
195
|
+
*/
|
|
196
|
+
export declare const ListModuleDeclarations: () => Promise<Record<string, ModuleDeclaration>>;
|
|
197
|
+
/**
|
|
198
|
+
* Write a module's declaration into the project's configuration file.
|
|
199
|
+
*
|
|
200
|
+
* Only the given fields of the module's entry are rewritten, and the entry is
|
|
201
|
+
* added when the file has none: every other line of the file, comments and
|
|
202
|
+
* expressions included, stays as it was. The running project is not
|
|
203
|
+
* restarted for this write; the caller loads, stops or reloads the module
|
|
204
|
+
* itself.
|
|
205
|
+
*
|
|
206
|
+
* @param module The module's key in `modules`
|
|
207
|
+
* @param changes The fields to write
|
|
208
|
+
* @throws Error if the file has no `modules` object it can edit, such as a
|
|
209
|
+
* configuration built by a function
|
|
210
|
+
*/
|
|
211
|
+
export declare const SaveModuleDeclaration: (module: string, changes: Partial<ModuleDeclaration>) => Promise<void>;
|
|
212
|
+
/**
|
|
213
|
+
* Remove a module's entry from the project's configuration file, leaving the
|
|
214
|
+
* rest of the file as it was and the running project unrestarted.
|
|
215
|
+
*
|
|
216
|
+
* @param module The module's key in `modules`
|
|
217
|
+
*/
|
|
218
|
+
export declare const RemoveModuleDeclaration: (module: string) => Promise<void>;
|
package/dist/modules.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ReloadModule = exports.DestroyModule = exports.StopModule = exports.StartModule = exports.LoadModule = exports.GetModuleInfo = exports.ListModules = exports.Events = void 0;
|
|
3
|
+
exports.RemoveModuleDeclaration = exports.SaveModuleDeclaration = exports.ListModuleDeclarations = exports.ReloadModule = exports.DestroyModule = exports.StopModule = exports.StartModule = exports.LoadModule = exports.GetModuleInfo = exports.ListModules = exports.Events = void 0;
|
|
4
4
|
exports.RunWithModuleContext = RunWithModuleContext;
|
|
5
5
|
exports.GetModuleContext = GetModuleContext;
|
|
6
6
|
exports.ReleaseOwner = ReleaseOwner;
|
|
@@ -214,4 +214,33 @@ exports.DestroyModule = (0, proxies_1.InterfaceFunction)("modules.DestroyModule"
|
|
|
214
214
|
* @throws Error if the module cannot be reloaded
|
|
215
215
|
*/
|
|
216
216
|
exports.ReloadModule = (0, proxies_1.InterfaceFunction)("modules.ReloadModule");
|
|
217
|
+
/**
|
|
218
|
+
* List the modules the project's configuration file declares, by key,
|
|
219
|
+
* disabled ones included.
|
|
220
|
+
*
|
|
221
|
+
* @returns The declarations of the top-level `modules` of the file
|
|
222
|
+
*/
|
|
223
|
+
exports.ListModuleDeclarations = (0, proxies_1.InterfaceFunction)("modules.ListModuleDeclarations");
|
|
224
|
+
/**
|
|
225
|
+
* Write a module's declaration into the project's configuration file.
|
|
226
|
+
*
|
|
227
|
+
* Only the given fields of the module's entry are rewritten, and the entry is
|
|
228
|
+
* added when the file has none: every other line of the file, comments and
|
|
229
|
+
* expressions included, stays as it was. The running project is not
|
|
230
|
+
* restarted for this write; the caller loads, stops or reloads the module
|
|
231
|
+
* itself.
|
|
232
|
+
*
|
|
233
|
+
* @param module The module's key in `modules`
|
|
234
|
+
* @param changes The fields to write
|
|
235
|
+
* @throws Error if the file has no `modules` object it can edit, such as a
|
|
236
|
+
* configuration built by a function
|
|
237
|
+
*/
|
|
238
|
+
exports.SaveModuleDeclaration = (0, proxies_1.InterfaceFunction)("modules.SaveModuleDeclaration");
|
|
239
|
+
/**
|
|
240
|
+
* Remove a module's entry from the project's configuration file, leaving the
|
|
241
|
+
* rest of the file as it was and the running project unrestarted.
|
|
242
|
+
*
|
|
243
|
+
* @param module The module's key in `modules`
|
|
244
|
+
*/
|
|
245
|
+
exports.RemoveModuleDeclaration = (0, proxies_1.InterfaceFunction)("modules.RemoveModuleDeclaration");
|
|
217
246
|
//# sourceMappingURL=modules.js.map
|
package/dist/modules.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"modules.js","sourceRoot":"","sources":["../src/modules.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"modules.js","sourceRoot":"","sources":["../src/modules.ts"],"names":[],"mappings":";;;AAaA,oDAKC;AAGD,4CAEC;AAiJD,oCAEC;AAzKD,uCAA0D;AAC1D,yCAQoB;AAEpB,oFAAoF;AACpF,SAAgB,oBAAoB,CAClC,OAA+B,EAC/B,QAAiB;IAEjB,OAAO,IAAA,+BAAoB,EAAC,OAAO,EAAE,QAAQ,CAAC,CAAC;AACjD,CAAC;AAED,kEAAkE;AAClE,SAAgB,gBAAgB;IAC9B,OAAO,IAAA,2BAAgB,GAAE,CAAC;AAC5B,CAAC;AAID;;;;;GAKG;AACH,IAAiB,MAAM,CAgDtB;AAhDD,WAAiB,MAAM;IACrB;;;;;;;OAOG;IACU,wBAAiB,GAAG,IAAI,oBAAU,CAC7C,2BAA2B,CAC5B,CAAC;IAEF;;;;;;;OAOG;IACU,oBAAa,GAAG,IAAI,oBAAU,CACzC,uBAAuB,CACxB,CAAC;IAEF;;;;;;;OAOG;IACU,oBAAa,G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A,WAAW,GAAG,IAAA,2BAAiB,EAC1C,qBAAqB,CACtB,CAAC;AAEF;;;;;;;;GAQG;AACU,QAAA,aAAa,GAAG,IAAA,2BAAiB,EAC5C,uBAAuB,CACxB,CAAC;AAEF;;;;;;;;;GASG;AACU,QAAA,UAAU,GACrB,IAAA,2BAAiB,EAMf,oBAAoB,CAAC,CAAC;AAE1B;;;;;;;;GAQG;AACU,QAAA,WAAW,GAAG,IAAA,2BAAiB,EAC1C,qBAAqB,CACtB,CAAC;AAEF;;;;;;;;GAQG;AACU,QAAA,UAAU,GACrB,IAAA,2BAAiB,EAA2B,oBAAoB,CAAC,CAAC;AAEpE;;;;;;;;GAQG;AACU,QAAA,aAAa,GAAG,IAAA,2BAAiB,EAC5C,uBAAuB,CACxB,CAAC;AAEF;;;;;;;;;GASG;AACU,QAAA,YAAY,GAAG,IAAA,2BAAiB,EAC3C,sBAAsB,CACvB,CAAC;AAiBF;;;;;GAKG;AACU,QAAA,sBAAsB,GAAG,IAAA,2BAAiB,EAErD,gCAAgC,CAAC,CAAC;AAEpC;;;;;;;;;;;;;GAaG;AACU,QAAA,qBAAqB,GAAG,IAAA,2BAAiB,EAEpD,+BAA+B,CAAC,CAAC;AAEnC;;;;;GAKG;AACU,QAAA,uBAAuB,GAAG,IAAA,2BAAiB,EAEtD,iCAAiC,CAAC,CAAC"}
|
package/docs/5.modules.md
CHANGED
|
@@ -174,6 +174,37 @@ Stops, destroys, unloads, and reloads a module from its source. This is useful f
|
|
|
174
174
|
await ReloadModule("my-module");
|
|
175
175
|
```
|
|
176
176
|
|
|
177
|
+
## Declaration functions
|
|
178
|
+
|
|
179
|
+
These functions read and edit the `modules` of the project's `antelope.config.ts`, for a module that installs or removes other modules and wants the change to survive a restart.
|
|
180
|
+
|
|
181
|
+
### `ListModuleDeclarations`
|
|
182
|
+
|
|
183
|
+
Returns the modules the configuration file declares at its top level, by key, shorthand entries expanded and disabled ones included.
|
|
184
|
+
|
|
185
|
+
```ts
|
|
186
|
+
const declarations = await ListModuleDeclarations();
|
|
187
|
+
```
|
|
188
|
+
|
|
189
|
+
### `SaveModuleDeclaration`
|
|
190
|
+
|
|
191
|
+
Writes the given fields of a module's entry, adding the entry when the file has none. Only those fields are rewritten: every other line of the file, comments and expressions included, stays as it was. A field set to `undefined` or `null` is removed. The running project does not restart for this write; the caller loads, stops or reloads the module itself.
|
|
192
|
+
|
|
193
|
+
```ts
|
|
194
|
+
await LoadModule("@acme/reports", { source }, true);
|
|
195
|
+
await SaveModuleDeclaration("@acme/reports", { source, optional: true });
|
|
196
|
+
```
|
|
197
|
+
|
|
198
|
+
It throws when the file has no `modules` object it can edit, such as a configuration built by a function.
|
|
199
|
+
|
|
200
|
+
### `RemoveModuleDeclaration`
|
|
201
|
+
|
|
202
|
+
Removes a module's entry, leaving the rest of the file as it was and the project running.
|
|
203
|
+
|
|
204
|
+
```ts
|
|
205
|
+
await RemoveModuleDeclaration("@acme/reports");
|
|
206
|
+
```
|
|
207
|
+
|
|
177
208
|
## `ModuleDefinition`
|
|
178
209
|
|
|
179
210
|
The configuration object for defining a module.
|
package/docs/7.configuration.md
CHANGED
|
@@ -154,14 +154,16 @@ Like the local source, `local-folder` also accepts an optional `reloadCommand` t
|
|
|
154
154
|
|
|
155
155
|
Full module configuration within the project config.
|
|
156
156
|
|
|
157
|
-
| Property | Type | Description
|
|
158
|
-
| ----------------- | -------------------------------------------- |
|
|
159
|
-
| `version` | `string` | Optional version constraint
|
|
160
|
-
| `source` | `ModuleSource*` | Source definition (local, git, package, local-folder)
|
|
161
|
-
| `config` | `unknown` | Optional runtime configuration
|
|
162
|
-
| `importOverrides` | `ImportOverride[] \| Record<string, string>` | Optional providers pinned for the interfaces the module uses, and named connections
|
|
163
|
-
| `disabledExports` | `string[]` | Optional list of exports to disable
|
|
164
|
-
| `exportPriority` | `Record<string, number>` | Optional priority of this module as the default provider of each interface it implements (default 0; highest wins)
|
|
157
|
+
| Property | Type | Description |
|
|
158
|
+
| ----------------- | -------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------- |
|
|
159
|
+
| `version` | `string` | Optional version constraint |
|
|
160
|
+
| `source` | `ModuleSource*` | Source definition (local, git, package, local-folder) |
|
|
161
|
+
| `config` | `unknown` | Optional runtime configuration |
|
|
162
|
+
| `importOverrides` | `ImportOverride[] \| Record<string, string>` | Optional providers pinned for the interfaces the module uses, and named connections |
|
|
163
|
+
| `disabledExports` | `string[]` | Optional list of exports to disable |
|
|
164
|
+
| `exportPriority` | `Record<string, number>` | Optional priority of this module as the default provider of each interface it implements (default 0; highest wins) |
|
|
165
|
+
| `disabled` | `boolean` | Keeps the module declared, with its configuration, without loading it |
|
|
166
|
+
| `optional` | `boolean` | Loads the module once the others have started; a failure to download, construct or start it is logged and the project runs on without it |
|
|
165
167
|
|
|
166
168
|
An `ImportOverride` is `{ interface, source?, id? }`. The first entry for an interface pins it to the `source` module; further entries are connections reached through `GetInterfaceInstance(interface, id)`. An entry for a standalone interface may omit `source`, declaring a connection to that self-hosted interface.
|
|
167
169
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@antelopejs/interface-core",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.1",
|
|
4
4
|
"description": "AntelopeJS core interface primitives - proxies, decorators, interface functions, and logging",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"antelopejs",
|
|
@@ -90,7 +90,7 @@
|
|
|
90
90
|
"reflect-metadata": "^0.2.2"
|
|
91
91
|
},
|
|
92
92
|
"devDependencies": {
|
|
93
|
-
"@antelopejs/tooling-configs": "^0.0.
|
|
93
|
+
"@antelopejs/tooling-configs": "^0.0.8",
|
|
94
94
|
"@types/chai": "^4.3.20",
|
|
95
95
|
"@types/mocha": "^10.0.10",
|
|
96
96
|
"@types/node": "^22.19.15",
|