@jskit-ai/kernel 0.1.151 → 0.1.152
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/internal/node/installedPackages.js +20 -0
- package/internal/node/installedPackages.test.js +51 -0
- package/package.json +1 -1
- package/server/exportPolicy.test.js +1 -1
- package/server/registries/serviceRegistrationRegistry.js +3 -2
- package/server/runtime/errors.test.js +1 -1
- package/server/runtime/serviceRegistration.test.js +3 -7
- package/shared/actions/actionDefinitions.test.js +3 -3
- package/shared/support/shellLayoutTargets.js +0 -7
- package/shared/support/shellLayoutTargets.test.js +4 -4
|
@@ -10,6 +10,17 @@ const ROOT_DEPENDENCY_SECTIONS = Object.freeze([
|
|
|
10
10
|
"peerDependencies",
|
|
11
11
|
"devDependencies"
|
|
12
12
|
]);
|
|
13
|
+
const JSKIT_PACKAGE_CONFIG_KEYS = Object.freeze([
|
|
14
|
+
"capabilities",
|
|
15
|
+
"ci",
|
|
16
|
+
"kind",
|
|
17
|
+
"lifecycle",
|
|
18
|
+
"metadata",
|
|
19
|
+
"mutations",
|
|
20
|
+
"optionPolicies",
|
|
21
|
+
"options",
|
|
22
|
+
"runtime"
|
|
23
|
+
]);
|
|
13
24
|
|
|
14
25
|
async function readJsonFile(filePath, fallback = {}) {
|
|
15
26
|
try {
|
|
@@ -57,6 +68,14 @@ function createPackageMetadata(packageJson = {}) {
|
|
|
57
68
|
if (!packageId || !version) {
|
|
58
69
|
return null;
|
|
59
70
|
}
|
|
71
|
+
const unknownKeys = Object.keys(jskit)
|
|
72
|
+
.filter((key) => !JSKIT_PACKAGE_CONFIG_KEYS.includes(key))
|
|
73
|
+
.sort();
|
|
74
|
+
if (unknownKeys.length > 0) {
|
|
75
|
+
throw new Error(
|
|
76
|
+
`${packageId} package.json#jskit contains unknown ${unknownKeys.length === 1 ? "field" : "fields"}: ${unknownKeys.join(", ")}.`
|
|
77
|
+
);
|
|
78
|
+
}
|
|
60
79
|
|
|
61
80
|
return Object.freeze({
|
|
62
81
|
...jskit,
|
|
@@ -275,6 +294,7 @@ async function discoverInstalledPackages({ appRoot } = {}) {
|
|
|
275
294
|
}
|
|
276
295
|
|
|
277
296
|
export {
|
|
297
|
+
JSKIT_PACKAGE_CONFIG_KEYS,
|
|
278
298
|
ROOT_DEPENDENCY_SECTIONS,
|
|
279
299
|
collectPackageDependencyIds,
|
|
280
300
|
collectRootDependencySpecifiers,
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import assert from "node:assert/strict";
|
|
2
|
+
import test from "node:test";
|
|
3
|
+
import {
|
|
4
|
+
createPackageMetadata,
|
|
5
|
+
JSKIT_PACKAGE_CONFIG_KEYS
|
|
6
|
+
} from "./installedPackages.js";
|
|
7
|
+
|
|
8
|
+
test("createPackageMetadata derives package identity from package.json", () => {
|
|
9
|
+
const metadata = createPackageMetadata({
|
|
10
|
+
name: "@example/runtime",
|
|
11
|
+
version: "0.1.0",
|
|
12
|
+
description: "Example runtime.",
|
|
13
|
+
jskit: {
|
|
14
|
+
kind: "runtime",
|
|
15
|
+
runtime: {
|
|
16
|
+
server: {
|
|
17
|
+
providers: []
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
assert.equal(metadata.packageId, "@example/runtime");
|
|
24
|
+
assert.equal(metadata.version, "0.1.0");
|
|
25
|
+
assert.equal(metadata.description, "Example runtime.");
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
test("createPackageMetadata accepts only the canonical package.json.jskit fields", () => {
|
|
29
|
+
assert.deepEqual(JSKIT_PACKAGE_CONFIG_KEYS, [
|
|
30
|
+
"capabilities",
|
|
31
|
+
"ci",
|
|
32
|
+
"kind",
|
|
33
|
+
"lifecycle",
|
|
34
|
+
"metadata",
|
|
35
|
+
"mutations",
|
|
36
|
+
"optionPolicies",
|
|
37
|
+
"options",
|
|
38
|
+
"runtime"
|
|
39
|
+
]);
|
|
40
|
+
assert.throws(
|
|
41
|
+
() => createPackageMetadata({
|
|
42
|
+
name: "@example/runtime",
|
|
43
|
+
version: "0.1.0",
|
|
44
|
+
jskit: {
|
|
45
|
+
kind: "runtime",
|
|
46
|
+
packageId: "@example/other-runtime"
|
|
47
|
+
}
|
|
48
|
+
}),
|
|
49
|
+
/unknown field: packageId/
|
|
50
|
+
);
|
|
51
|
+
});
|
package/package.json
CHANGED
|
@@ -61,7 +61,7 @@ test("kernel exported JS targets do not use star re-exports", async () => {
|
|
|
61
61
|
assert.deepEqual(violations, []);
|
|
62
62
|
});
|
|
63
63
|
|
|
64
|
-
test("kernel package
|
|
64
|
+
test("kernel package exposes only its declared entrypoints", async () => {
|
|
65
65
|
const packageJsonPath = path.join(PACKAGE_ROOT, "package.json");
|
|
66
66
|
const packageJson = JSON.parse(await readFile(packageJsonPath, "utf8"));
|
|
67
67
|
assert.equal(Object.hasOwn(packageJson.exports || {}, "./server"), false);
|
|
@@ -145,8 +145,9 @@ function normalizeServiceEventSpec(entry, { context = "service event" } = {}) {
|
|
|
145
145
|
|
|
146
146
|
function normalizeServiceMetadata(value = {}) {
|
|
147
147
|
const source = normalizeObject(value);
|
|
148
|
-
|
|
149
|
-
|
|
148
|
+
const unsupportedFields = Object.keys(source).filter((key) => key !== "events");
|
|
149
|
+
if (unsupportedFields.length > 0) {
|
|
150
|
+
throw new TypeError(`service metadata supports only events. Received: ${unsupportedFields.sort().join(", ")}.`);
|
|
150
151
|
}
|
|
151
152
|
const eventsSource = normalizeObject(source.events);
|
|
152
153
|
const events = {};
|
|
@@ -60,7 +60,7 @@ test("isDomainError identifies DomainError subclasses and isAppError remains tru
|
|
|
60
60
|
assert.equal(isAppError(appError), true);
|
|
61
61
|
});
|
|
62
62
|
|
|
63
|
-
test("createValidationError
|
|
63
|
+
test("createValidationError creates a 400 response with field errors", () => {
|
|
64
64
|
const error = createValidationError({ email: "Invalid." });
|
|
65
65
|
|
|
66
66
|
assert.equal(error.status, 400);
|
|
@@ -63,7 +63,7 @@ test("installServiceRegistrationApi exposes app.service and publishes declared e
|
|
|
63
63
|
assert.equal(published[0].meta?.realtime?.event, "customers.record.changed");
|
|
64
64
|
});
|
|
65
65
|
|
|
66
|
-
test("app.service rejects
|
|
66
|
+
test("app.service rejects unknown metadata fields", () => {
|
|
67
67
|
const app = createContainer();
|
|
68
68
|
app.singleton("domainEvents", () => ({
|
|
69
69
|
async publish() {
|
|
@@ -82,14 +82,10 @@ test("app.service rejects deprecated permissions metadata", () => {
|
|
|
82
82
|
}
|
|
83
83
|
}),
|
|
84
84
|
{
|
|
85
|
-
|
|
86
|
-
listRecords: {
|
|
87
|
-
require: "authenticated"
|
|
88
|
-
}
|
|
89
|
-
}
|
|
85
|
+
unexpected: true
|
|
90
86
|
}
|
|
91
87
|
),
|
|
92
|
-
/metadata
|
|
88
|
+
/metadata supports only events.*unexpected/
|
|
93
89
|
);
|
|
94
90
|
});
|
|
95
91
|
|
|
@@ -138,14 +138,14 @@ test("normalizeActionDefinition stays channel-agnostic and ignores unknown extra
|
|
|
138
138
|
schema: createSchema({})
|
|
139
139
|
},
|
|
140
140
|
idempotency: "none",
|
|
141
|
-
|
|
142
|
-
description: "
|
|
141
|
+
customExtension: {
|
|
142
|
+
description: "Ignored field"
|
|
143
143
|
},
|
|
144
144
|
execute: async () => ({})
|
|
145
145
|
});
|
|
146
146
|
|
|
147
147
|
assert.equal(typeof definition, "object");
|
|
148
|
-
assert.equal(Object.prototype.hasOwnProperty.call(definition, "
|
|
148
|
+
assert.equal(Object.prototype.hasOwnProperty.call(definition, "customExtension"), false);
|
|
149
149
|
});
|
|
150
150
|
|
|
151
151
|
test("normalizeActionOutputDefinition accepts single schema definitions", () => {
|
|
@@ -303,13 +303,6 @@ function normalizeShellOutletTargetRecord(
|
|
|
303
303
|
) {
|
|
304
304
|
const record = normalizeObject(value);
|
|
305
305
|
const resolvedContext = normalizeText(context) || "shell layout";
|
|
306
|
-
if (Object.hasOwn(record, "host") || Object.hasOwn(record, "position")) {
|
|
307
|
-
throw new Error(
|
|
308
|
-
`${resolvedContext} must declare ShellOutlet targets with "target" only. ` +
|
|
309
|
-
`Legacy "host" and "position" attributes are not supported.`
|
|
310
|
-
);
|
|
311
|
-
}
|
|
312
|
-
|
|
313
306
|
const targetParts = resolveShellOutletTargetParts(
|
|
314
307
|
{
|
|
315
308
|
target: record.target
|
|
@@ -106,15 +106,15 @@ test("discoverShellOutletTargetsFromVueSource ignores disabled default markers",
|
|
|
106
106
|
assert.equal(discovered.defaultTargetId, "");
|
|
107
107
|
});
|
|
108
108
|
|
|
109
|
-
test("discoverShellOutletTargetsFromVueSource
|
|
109
|
+
test("discoverShellOutletTargetsFromVueSource reads the target attribute", () => {
|
|
110
110
|
const source = `
|
|
111
111
|
<template>
|
|
112
112
|
<ShellOutlet target="shell-layout:primary-menu" host="other-host" position="primary-menu" />
|
|
113
113
|
</template>
|
|
114
114
|
`;
|
|
115
115
|
|
|
116
|
-
assert.
|
|
117
|
-
|
|
118
|
-
|
|
116
|
+
assert.deepEqual(
|
|
117
|
+
discoverShellOutletTargetsFromVueSource(source, { context: "ShellLayout.vue" }).targets,
|
|
118
|
+
[{ id: "shell-layout:primary-menu", default: false }]
|
|
119
119
|
);
|
|
120
120
|
});
|