nervur 0.8.1 → 0.8.2
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/blueprint.mjs +11 -8
- package/package.json +2 -2
package/blueprint.mjs
CHANGED
|
@@ -80,6 +80,9 @@ const RESERVED = ['eval', 'import', '__proto__', 'prototype', 'Math.random'];
|
|
|
80
80
|
|
|
81
81
|
const SHADOWED = FORBIDDEN.map(([name]) => name).filter((name) => !RESERVED.includes(name));
|
|
82
82
|
|
|
83
|
+
const doorHolder = (one) =>
|
|
84
|
+
one.kind === Kind.OBJECT_TYPE_DEFINITION || one.kind === Kind.OBJECT_TYPE_EXTENSION;
|
|
85
|
+
|
|
83
86
|
const RIGHTS_DIRECTIVE = 'directive @rights(is: [Rights!]!) on FIELD_DEFINITION';
|
|
84
87
|
|
|
85
88
|
const DEFAULT_RIGHTS = `enum Rights { SELF MEMBER STRANGER }`;
|
|
@@ -250,10 +253,10 @@ const Blueprint = (source) => {
|
|
|
250
253
|
];
|
|
251
254
|
|
|
252
255
|
const admits = (typeName, fieldName, held) => {
|
|
253
|
-
const
|
|
254
|
-
(one) => one
|
|
255
|
-
|
|
256
|
-
|
|
256
|
+
const field = document.definitions
|
|
257
|
+
.filter((one) => doorHolder(one) && one.name.value === typeName)
|
|
258
|
+
.flatMap((one) => one.fields ?? [])
|
|
259
|
+
.find((one) => one.name.value === fieldName);
|
|
257
260
|
const allowed = field === undefined ? undefined : rightsOf(field);
|
|
258
261
|
return allowed === undefined ? true : allowed.includes(held);
|
|
259
262
|
};
|
|
@@ -273,7 +276,7 @@ const Blueprint = (source) => {
|
|
|
273
276
|
schema.getSubscriptionType()?.name,
|
|
274
277
|
].filter((one) => one !== undefined);
|
|
275
278
|
const undeclared = document.definitions
|
|
276
|
-
.filter((one) => one
|
|
279
|
+
.filter((one) => doorHolder(one) && roots.includes(one.name.value))
|
|
277
280
|
.flatMap((one) => one.fields ?? [])
|
|
278
281
|
.filter((one) => {
|
|
279
282
|
const allowed = rightsOf(one);
|
|
@@ -321,17 +324,17 @@ const Blueprint = (source) => {
|
|
|
321
324
|
...document,
|
|
322
325
|
definitions: document.definitions
|
|
323
326
|
.map((one) =>
|
|
324
|
-
one
|
|
327
|
+
doorHolder(one)
|
|
325
328
|
? {
|
|
326
329
|
...one,
|
|
327
|
-
fields: one.fields.filter((field) => {
|
|
330
|
+
fields: (one.fields ?? []).filter((field) => {
|
|
328
331
|
const allowed = rightsOf(field);
|
|
329
332
|
return allowed === undefined || allowed.includes(held);
|
|
330
333
|
}),
|
|
331
334
|
}
|
|
332
335
|
: one,
|
|
333
336
|
)
|
|
334
|
-
.filter((one) => one
|
|
337
|
+
.filter((one) => !doorHolder(one) || one.fields.length > 0),
|
|
335
338
|
}),
|
|
336
339
|
trespass: [],
|
|
337
340
|
});
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "nervur",
|
|
3
|
-
"version": "0.8.
|
|
4
|
-
"description": "A distributed system of sovereign beings
|
|
3
|
+
"version": "0.8.2",
|
|
4
|
+
"description": "A distributed system of sovereign beings \u2014 one door, one question: by whose authority.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"author": "Razvan Gherghina",
|
|
7
7
|
"homepage": "https://nervur.org",
|