@venizia/ardor-kernel 0.5.0-7 → 0.5.0-9
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.
|
@@ -84,6 +84,9 @@ export declare abstract class AbstractArdorApplication extends Container {
|
|
|
84
84
|
* its inlined `content` is checked.
|
|
85
85
|
*/
|
|
86
86
|
private assertIndexed;
|
|
87
|
+
/** Every class list of an index: the six built-in fields, then `custom.<type>` for each defined type. */
|
|
88
|
+
private static listsOf;
|
|
89
|
+
private assertListed;
|
|
87
90
|
/**
|
|
88
91
|
* Binds the features after the stereotypes, so `bindingList()` and `bindContext()` still override
|
|
89
92
|
* what a feature provides. A name is unique, and every configuration and artifact a feature lists
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ArtifactBindingKeys, ArtifactGroup, ArtifactNamespaces, BindingNamespaces, MetadataRegistry, } from '@venizia/ignis-kernel/metadata';
|
|
1
|
+
import { ArtifactBindingKeys, ArtifactGroup, ArtifactNamespaces, ArtifactTypes, BindingNamespaces, MetadataRegistry, } from '@venizia/ignis-kernel/metadata';
|
|
2
2
|
import { BindingKeys, BindingScopes, Container, getError, } from '@venizia/ignis-inversion';
|
|
3
3
|
import { CoreBindings, } from '../../common/index.js';
|
|
4
4
|
import { ApplicationInfoGuard } from './app-info.js';
|
|
@@ -96,9 +96,10 @@ export class AbstractArdorApplication extends Container {
|
|
|
96
96
|
if (metadata?.allowOverride === false) {
|
|
97
97
|
this.lockedKeys.set(key, target);
|
|
98
98
|
}
|
|
99
|
+
const definition = metadata ? ArtifactTypes.definitionOf({ type: metadata.type }) : undefined;
|
|
99
100
|
this.bind({ key })
|
|
100
101
|
.toClass(target)
|
|
101
|
-
.setScope(metadata?.scope ?? BindingScopes.SINGLETON);
|
|
102
|
+
.setScope(metadata?.scope ?? definition?.scope ?? BindingScopes.SINGLETON);
|
|
102
103
|
for (const entry of registry.getProvideMetadata({ target })) {
|
|
103
104
|
this.bind({ key: entry.key })
|
|
104
105
|
.toProvider((container) => {
|
|
@@ -219,21 +220,36 @@ export class AbstractArdorApplication extends Container {
|
|
|
219
220
|
if (!index) {
|
|
220
221
|
continue;
|
|
221
222
|
}
|
|
222
|
-
for (const
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
223
|
+
for (const { field, targets } of AbstractArdorApplication.listsOf({ index })) {
|
|
224
|
+
this.assertListed({ field, targets, discovered });
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
/** Every class list of an index: the six built-in fields, then `custom.<type>` for each defined type. */
|
|
229
|
+
static listsOf(opts) {
|
|
230
|
+
const { index } = opts;
|
|
231
|
+
return [
|
|
232
|
+
...ArtifactIndexKinds.map((field) => ({ field, targets: index[field] ?? [] })),
|
|
233
|
+
...Object.entries(index.custom ?? {}).map(([type, targets]) => ({
|
|
234
|
+
field: `custom.${type}`,
|
|
235
|
+
targets,
|
|
236
|
+
})),
|
|
237
|
+
];
|
|
238
|
+
}
|
|
239
|
+
assertListed(opts) {
|
|
240
|
+
const { field, targets, discovered } = opts;
|
|
241
|
+
for (const [position, target] of targets.entries()) {
|
|
242
|
+
// A cycle leaves `undefined` here: a bundler's eager class list is built while the module of
|
|
243
|
+
// the class is still evaluating. Say so, rather than fail on `.name` below.
|
|
244
|
+
if (typeof target !== 'function') {
|
|
245
|
+
throw getError({
|
|
246
|
+
message: `[artifacts] '${field}' lists an entry that is not a class (position ${position}) | Usually an import cycle: the module that imports the index (or @venizia/ignis-boot/auto) must not define decorated classes or be imported by them`,
|
|
247
|
+
});
|
|
248
|
+
}
|
|
249
|
+
if (!discovered.has(target)) {
|
|
250
|
+
throw getError({
|
|
251
|
+
message: `[artifacts] '${field}' lists ${target.name}, which was never discovered | Decorate it with its stereotype and regenerate the index`,
|
|
252
|
+
});
|
|
237
253
|
}
|
|
238
254
|
}
|
|
239
255
|
}
|
|
@@ -260,16 +276,18 @@ export class AbstractArdorApplication extends Container {
|
|
|
260
276
|
});
|
|
261
277
|
}
|
|
262
278
|
}
|
|
263
|
-
for (const
|
|
264
|
-
|
|
279
|
+
for (const { field, targets } of AbstractArdorApplication.listsOf({
|
|
280
|
+
index: feature.artifacts ?? {},
|
|
281
|
+
})) {
|
|
282
|
+
for (const [position, target] of targets.entries()) {
|
|
265
283
|
if (typeof target !== 'function') {
|
|
266
284
|
throw getError({
|
|
267
|
-
message: `[features] '${feature.name}' lists an entry in artifacts.${
|
|
285
|
+
message: `[features] '${feature.name}' lists an entry in artifacts.${field} that is not a class (position ${position}) | Usually an import cycle: the feature module must not be imported by the classes it lists`,
|
|
268
286
|
});
|
|
269
287
|
}
|
|
270
288
|
if (!discovered.has(target)) {
|
|
271
289
|
throw getError({
|
|
272
|
-
message: `[features] '${feature.name}' lists ${target.name} in artifacts.${
|
|
290
|
+
message: `[features] '${feature.name}' lists ${target.name} in artifacts.${field}, which was never discovered | Decorate it with its stereotype and import its module before start()`,
|
|
273
291
|
});
|
|
274
292
|
}
|
|
275
293
|
}
|
package/dist/common/types.d.ts
CHANGED
|
@@ -281,6 +281,8 @@ export interface IArtifactIndex {
|
|
|
281
281
|
repositories?: ReadonlyArray<TClass<unknown>>;
|
|
282
282
|
services?: ReadonlyArray<TClass<unknown>>;
|
|
283
283
|
controllers?: ReadonlyArray<TClass<unknown>>;
|
|
284
|
+
/** The classes of the types the application declared with `ArtifactTypes.define`, by type name. */
|
|
285
|
+
custom?: Readonly<Record<string, ReadonlyArray<TClass<unknown>>>>;
|
|
284
286
|
}
|
|
285
287
|
/**
|
|
286
288
|
* Answers whether the current actor may act on a resource. Bound by the application under
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@venizia/ardor-kernel",
|
|
3
|
-
"version": "0.5.0-
|
|
3
|
+
"version": "0.5.0-9",
|
|
4
4
|
"description": "ARDOR kernel - the isomorphic core of the ARDOR frontend framework: application base on IGNIS inversion, service and provider bases, request/auth constants, binding keys, the network request service, runtime config and the HTTP repository (from IGNIS). No React and no react-admin.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ardor",
|
|
@@ -73,11 +73,11 @@
|
|
|
73
73
|
"@size-limit/preset-small-lib": "^14.2.0",
|
|
74
74
|
"@types/bun": "^1.4.5",
|
|
75
75
|
"@venizia/dev-configs": "^0.5.0-6",
|
|
76
|
-
"@venizia/ignis-connectors": "^0.5.0-
|
|
77
|
-
"@venizia/ignis-filter": "^0.5.0-
|
|
78
|
-
"@venizia/ignis-helpers": "^0.5.0-
|
|
79
|
-
"@venizia/ignis-inversion": "^0.5.0-
|
|
80
|
-
"@venizia/ignis-kernel": "^0.5.0-
|
|
76
|
+
"@venizia/ignis-connectors": "^0.5.0-9",
|
|
77
|
+
"@venizia/ignis-filter": "^0.5.0-3",
|
|
78
|
+
"@venizia/ignis-helpers": "^0.5.0-7",
|
|
79
|
+
"@venizia/ignis-inversion": "^0.5.0-3",
|
|
80
|
+
"@venizia/ignis-kernel": "^0.5.0-8",
|
|
81
81
|
"eslint": "^10.13.0",
|
|
82
82
|
"oxlint": "1.89.0",
|
|
83
83
|
"oxlint-tsgolint": "7.0.2004",
|
|
@@ -87,11 +87,11 @@
|
|
|
87
87
|
"typescript": "^6.0.3"
|
|
88
88
|
},
|
|
89
89
|
"peerDependencies": {
|
|
90
|
-
"@venizia/ignis-connectors": "^0.5.0-
|
|
91
|
-
"@venizia/ignis-filter": "^0.5.0-
|
|
92
|
-
"@venizia/ignis-helpers": "^0.5.0-
|
|
93
|
-
"@venizia/ignis-inversion": "^0.5.0-
|
|
94
|
-
"@venizia/ignis-kernel": "^0.5.0-
|
|
90
|
+
"@venizia/ignis-connectors": "^0.5.0-9",
|
|
91
|
+
"@venizia/ignis-filter": "^0.5.0-3",
|
|
92
|
+
"@venizia/ignis-helpers": "^0.5.0-7",
|
|
93
|
+
"@venizia/ignis-inversion": "^0.5.0-3",
|
|
94
|
+
"@venizia/ignis-kernel": "^0.5.0-8",
|
|
95
95
|
"reflect-metadata": ">=0.2.2"
|
|
96
96
|
},
|
|
97
97
|
"peerDependenciesMeta": {
|