nervur 0.7.6 → 0.8.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/being.mjs +13 -1
- package/blueprint.mjs +1 -0
- package/ground.mjs +22 -2
- package/package.json +1 -1
- package/program.mjs +1 -0
package/being.mjs
CHANGED
|
@@ -39,6 +39,17 @@ const Compartment = ({ memory, voice, address, root, classOf }) => {
|
|
|
39
39
|
});
|
|
40
40
|
};
|
|
41
41
|
|
|
42
|
+
const offered = (modules, program, mine) =>
|
|
43
|
+
Object.freeze({
|
|
44
|
+
...Object.fromEntries(
|
|
45
|
+
(program?.modules ?? [])
|
|
46
|
+
.map((one) => one.module)
|
|
47
|
+
.filter((name) => name !== 'memory' && modules[name] !== undefined)
|
|
48
|
+
.map((name) => [name, modules[name]]),
|
|
49
|
+
),
|
|
50
|
+
memory: scoped(mine, program),
|
|
51
|
+
});
|
|
52
|
+
|
|
42
53
|
const grantable = (program) =>
|
|
43
54
|
(program?.rights ?? [...STRUCTURAL, 'MEMBER']).filter((one) => !STRUCTURAL.includes(one));
|
|
44
55
|
|
|
@@ -240,7 +251,8 @@ const Being = ({ voice, address, deliver, modules, registry, vouched, watch }) =
|
|
|
240
251
|
}
|
|
241
252
|
const asked = await program.ask({
|
|
242
253
|
context: {
|
|
243
|
-
|
|
254
|
+
from: program.caller ? from : undefined,
|
|
255
|
+
modules: offered(modules, program, mine),
|
|
244
256
|
port: Port({ voice, mine, deliver, rights }),
|
|
245
257
|
registry,
|
|
246
258
|
rights,
|
package/blueprint.mjs
CHANGED
package/ground.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ADMIN } from './admin.mjs';
|
|
2
2
|
import { Being, Compartment, Registry, make, rootFor } from './being.mjs';
|
|
3
|
-
import { coreClass } from './blueprint.mjs';
|
|
3
|
+
import { Blueprint, coreClass } from './blueprint.mjs';
|
|
4
4
|
import { Client } from './client.mjs';
|
|
5
5
|
import { Contracts } from './contract.mjs';
|
|
6
6
|
import { Memory, Paths, Wire } from './modules.mjs';
|
|
@@ -13,6 +13,22 @@ const GROUND = 'Ground';
|
|
|
13
13
|
|
|
14
14
|
const FLOOR = ['blueprints', 'cells', 'contracts', 'keychain', 'paths', 'watch', 'wire'];
|
|
15
15
|
|
|
16
|
+
const doorsOf = (source) => {
|
|
17
|
+
const written = Blueprint(source);
|
|
18
|
+
if (written === undefined) {
|
|
19
|
+
return undefined;
|
|
20
|
+
}
|
|
21
|
+
return [written.schema.getQueryType(), written.schema.getMutationType()]
|
|
22
|
+
.filter((one) => one !== undefined && one !== null)
|
|
23
|
+
.flatMap((one) => Object.keys(one.getFields()));
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
const redefines = (source) => {
|
|
27
|
+
const custom = doorsOf(source);
|
|
28
|
+
const standard = doorsOf(ADMIN);
|
|
29
|
+
return custom === undefined || custom.some((one) => standard.includes(one));
|
|
30
|
+
};
|
|
31
|
+
|
|
16
32
|
const install = ({ cells, keychain, program }) => {
|
|
17
33
|
const memory = Memory(cells);
|
|
18
34
|
const voice = Voice();
|
|
@@ -41,7 +57,11 @@ const Ground = (modules = {}) => {
|
|
|
41
57
|
return undefined;
|
|
42
58
|
}
|
|
43
59
|
|
|
44
|
-
const
|
|
60
|
+
const extension = modules.blueprints?.ground();
|
|
61
|
+
if (extension !== undefined && redefines(extension)) {
|
|
62
|
+
return undefined;
|
|
63
|
+
}
|
|
64
|
+
const program = extension ?? ADMIN;
|
|
45
65
|
if (cells.peek('ground/admin') === undefined) {
|
|
46
66
|
install({ cells, keychain, program });
|
|
47
67
|
}
|
package/package.json
CHANGED
package/program.mjs
CHANGED
|
@@ -52,6 +52,7 @@ const Program = (source) => {
|
|
|
52
52
|
return answered.errors === undefined ? { data: answered.data } : undefined;
|
|
53
53
|
},
|
|
54
54
|
bindings: blueprint.bindings,
|
|
55
|
+
caller: blueprint.caller,
|
|
55
56
|
classOf: blueprint.classOf,
|
|
56
57
|
config: blueprint.config,
|
|
57
58
|
declares: blueprint.declares,
|