@astrale-os/sdk 0.6.0-beta.56 → 0.6.0-beta.57
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/README.md +11 -10
- package/dist/application/index.d.ts +2 -1
- package/dist/application/query/execution/crossings.d.ts +6 -1
- package/dist/application/query/execution/crossings.js +15 -1
- package/dist/application/query/execution/legacy/declared-classes.d.ts +10 -0
- package/dist/application/query/execution/legacy/declared-classes.js +9 -0
- package/dist/application/requirements/canonical.d.ts +7 -0
- package/dist/application/requirements/canonical.js +16 -0
- package/dist/application/requirements/classes.d.ts +9 -7
- package/dist/application/requirements/classes.js +35 -42
- package/dist/application/requirements/functions.d.ts +3 -1
- package/dist/application/requirements/functions.js +12 -27
- package/dist/application/requirements/index.d.ts +34 -16
- package/dist/application/requirements/index.js +17 -20
- package/dist/application/requirements/legacy/authority.d.ts +21 -0
- package/dist/application/requirements/{authority.js → legacy/authority.js} +5 -2
- package/dist/application/requirements/legacy/classes.d.ts +22 -0
- package/dist/application/requirements/legacy/classes.js +24 -0
- package/dist/application/requirements/legacy/core.d.ts +30 -0
- package/dist/application/requirements/{core.js → legacy/core.js} +15 -13
- package/dist/application/requirements/legacy/functions.d.ts +7 -0
- package/dist/application/requirements/legacy/functions.js +15 -0
- package/dist/application/requirements/legacy/index.d.ts +43 -0
- package/dist/application/requirements/legacy/index.js +1 -0
- package/dist/application/requirements/legacy/requirements.d.ts +31 -0
- package/dist/application/requirements/legacy/requirements.js +31 -0
- package/dist/application/requirements/requirement.d.ts +30 -19
- package/dist/application/requirements/roles.d.ts +17 -0
- package/dist/application/requirements/roles.js +62 -0
- package/dist/application/requirements/scopes.d.ts +16 -0
- package/dist/application/requirements/scopes.js +34 -0
- package/dist/deployment/build/build.d.ts +3 -5
- package/dist/deployment/build/compile.js +12 -64
- package/dist/deployment/build/legacy/requirements.d.ts +11 -0
- package/dist/deployment/build/legacy/requirements.js +79 -0
- package/dist/deployment/build/material.js +0 -3
- package/dist/execution/invocation/dispatch/context.js +2 -1
- package/dist/platform/schema/class-authoring.d.ts +9 -7
- package/dist/platform/schema/class-authoring.js +3 -2
- package/dist/platform/schema/index.d.ts +1 -1
- package/dist/testing/query.js +2 -1
- package/dist/tooling/linter/adapters/typescript/discover.js +8 -2
- package/dist/tooling/linter/adapters/typescript/index.d.ts +6 -0
- package/dist/tooling/linter/adapters/typescript/index.js +1 -0
- package/dist/tooling/linter/adapters/typescript/legacy.d.ts +20 -0
- package/dist/tooling/linter/adapters/typescript/legacy.js +28 -0
- package/dist/tooling/linter/implementations/source/callable-requirements.d.ts +1 -2
- package/dist/tooling/linter/implementations/source/callable-requirements.js +7 -44
- package/dist/tooling/linter/implementations/source/const-initializer.d.ts +3 -0
- package/dist/tooling/linter/implementations/source/const-initializer.js +31 -0
- package/dist/tooling/linter/implementations/source/domain-requirements.d.ts +8 -0
- package/dist/tooling/linter/implementations/source/domain-requirements.js +35 -0
- package/dist/tooling/linter/implementations/source/global.js +21 -8
- package/dist/tooling/linter/implementations/source/legacy/requirements.d.ts +10 -0
- package/dist/tooling/linter/implementations/source/legacy/requirements.js +40 -0
- package/dist/tooling/linter/implementations/source/legacy-folders.d.ts +3 -0
- package/dist/tooling/linter/implementations/source/legacy-folders.js +126 -0
- package/dist/tooling/linter/implementations/source/mutations.js +7 -22
- package/dist/tooling/linter/implementations/source/requirement-entries.d.ts +24 -0
- package/dist/tooling/linter/implementations/source/requirement-entries.js +52 -0
- package/dist/tooling/linter/implementations/source/schema.d.ts +3 -0
- package/dist/tooling/linter/implementations/source/schema.js +9 -5
- package/dist/tooling/linter/implementations/source/tests.js +1 -1
- package/dist/tooling/linter/implementations/source/verifiers.js +2 -0
- package/dist/tooling/linter/policy/generated.js +2 -2
- package/dist/tooling/linter/requirements/registry.js +2 -0
- package/docs/accounts/scenarios.tsv +12 -0
- package/docs/handler-dependencies.md +5 -3
- package/docs/legacy.md +113 -0
- package/docs/queries.md +3 -2
- package/docs/requirements.md +134 -0
- package/package.json +2 -2
- package/dist/application/requirements/authority.d.ts +0 -7
- package/dist/application/requirements/core.d.ts +0 -14
package/README.md
CHANGED
|
@@ -151,9 +151,9 @@ export const purge = func({
|
|
|
151
151
|
|
|
152
152
|
A Class rule judges the caller, which passes by owning the Class's installation or by the rule,
|
|
153
153
|
never by a capability it holds. When a Domain acts for a caller, the Domain must also hold its own
|
|
154
|
-
right on the Class (the
|
|
154
|
+
right on the Class (the scope its requirements declare, or ownership), whatever the rule; an
|
|
155
155
|
Identity acting for itself delegates nothing and meets no such ceiling. A callable reads the same
|
|
156
|
-
way, with `
|
|
156
|
+
way, with its `call` scope (or ownership) as the right of its ceiling. `true` admits every Identity of the
|
|
157
157
|
instance, never an anonymous request.
|
|
158
158
|
|
|
159
159
|
| Declared | Caller is admitted when |
|
|
@@ -204,15 +204,16 @@ Error declarations are not yet published in the installed Kernel Schema.
|
|
|
204
204
|
|
|
205
205
|
## Development
|
|
206
206
|
|
|
207
|
-
###
|
|
207
|
+
### Requirements: Kernel Roles and scopes
|
|
208
208
|
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
209
|
+
`requirements({ roles, scopes })` declares what a Domain's release needs from an instance: each
|
|
210
|
+
Role binding names a Role (a Core Node of the Domain or of a dependency) and the holders that are
|
|
211
|
+
its `members` or its `granters` (one of the Domain's Core Identities, or `requirements.domain` for
|
|
212
|
+
the installed Domain itself); each scope names a Class with Class operations, or a Function or
|
|
213
|
+
Method with `call`. Builds emit them as the release's `requirements.capabilities.roles` and
|
|
214
|
+
`.scopes`, which the Kernel validates against the exact dependency closure. See
|
|
215
|
+
[Requirements](docs/requirements.md). The previous shape (`functions`, `classes`, `authority`,
|
|
216
|
+
`core`) still builds unchanged and is deprecated; see [the legacy method](docs/legacy.md).
|
|
216
217
|
|
|
217
218
|
### Durable schema installations
|
|
218
219
|
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
export { defineDomain, isDomainDefinition } from './define.js';
|
|
2
2
|
export type { DomainDefinitionInput } from './define.js';
|
|
3
3
|
export { requirements } from './requirements/index.js';
|
|
4
|
-
export type {
|
|
4
|
+
export type { CallableScopeRequirement, CallableScopeRequirementInput, ClassOperation, ClassScopeRequirement, ClassScopeRequirementInput, ClassTarget, CoreNodeInput, DomainHolder, FunctionRequirementTarget, HolderInput, RequirementHolder, Requirements, RequirementsFunction, RequirementsInput, RoleRequirement, RoleRequirementInput, RoleRequirements, RoleRequirementsInput, ScopeRequirement, ScopeRequirementInput, } from './requirements/index.js';
|
|
5
|
+
export type { AuthorityRequirements, AuthorityRequirementsInput, ClassRequirement, ClassRequirementInput, CoreRequirement, CoreRequirementInput, LegacyAuthorityRequirements, LegacyAuthorityRequirementsInput, LegacyClassRequirement, LegacyClassRequirementInput, LegacyCoreRequirement, LegacyCoreRequirementInput, LegacyRequirements, LegacyRequirementsInput, } from './requirements/index.js';
|
|
5
6
|
export { route, routes } from './routes/index.js';
|
|
6
7
|
export type { Route, RouteInput, RouteTarget, Routes } from './routes/index.js';
|
|
7
8
|
export { defineFrontend, external, vite } from './view/index.js';
|
|
@@ -1,11 +1,16 @@
|
|
|
1
1
|
import type { ClassRef, Domain } from '../../../platform/schema/index.js';
|
|
2
2
|
import type { Model } from '../handles/model.js';
|
|
3
3
|
import type { ReadPlan } from '../handles/plan.js';
|
|
4
|
-
/** A Class
|
|
4
|
+
/** A Class the Domain holds scopes on, and those scopes. */
|
|
5
5
|
export interface DeclaredClass {
|
|
6
6
|
readonly class: ClassRef;
|
|
7
7
|
readonly operations: readonly string[];
|
|
8
8
|
}
|
|
9
|
+
/**
|
|
10
|
+
* The Classes a Domain's requirements scope, authored or as a build compiled them: each Class
|
|
11
|
+
* scope, which bounds what the Domain reads for a caller. A scope on a callable names no Class.
|
|
12
|
+
*/
|
|
13
|
+
export declare function declaredClasses(capabilities: object): readonly DeclaredClass[];
|
|
9
14
|
/**
|
|
10
15
|
* The S12 refusal: a `TypeError`, the same for every input and every attempt, so a durable Step
|
|
11
16
|
* fails at once on it.
|
|
@@ -17,6 +17,20 @@
|
|
|
17
17
|
* written, so an empty list the input gives refuses what any other list does.
|
|
18
18
|
*/
|
|
19
19
|
import { Key } from '@astrale-os/kernel-dsl/v1/addressing';
|
|
20
|
+
import { isLegacyCapabilities } from '@astrale-os/kernel-protocol/release';
|
|
21
|
+
import { legacyDeclaredClasses } from './legacy/declared-classes.js';
|
|
22
|
+
/**
|
|
23
|
+
* The Classes a Domain's requirements scope, authored or as a build compiled them: each Class
|
|
24
|
+
* scope, which bounds what the Domain reads for a caller. A scope on a callable names no Class.
|
|
25
|
+
*/
|
|
26
|
+
export function declaredClasses(capabilities) {
|
|
27
|
+
// The one seam to the legacy shape: a key only that shape declares selects it.
|
|
28
|
+
if (isLegacyCapabilities(capabilities)) {
|
|
29
|
+
return legacyDeclaredClasses(capabilities);
|
|
30
|
+
}
|
|
31
|
+
const { scopes = [] } = capabilities;
|
|
32
|
+
return Object.freeze(scopes.flatMap(({ on, operations }) => typeof on === 'string' ? [] : [Object.freeze({ class: on, operations })]));
|
|
33
|
+
}
|
|
20
34
|
/**
|
|
21
35
|
* The Kernel's origin. Its Classes need nothing, even when the Domain declares it a dependency, but
|
|
22
36
|
* the dependency Classes under an abstract one (`Identity`, `Node`) each do.
|
|
@@ -165,7 +179,7 @@ export class Crossings {
|
|
|
165
179
|
'read',
|
|
166
180
|
];
|
|
167
181
|
throw new UndeclaredCrossing(query, `Query ${query}: ${relation} ${what}, a Class of the dependency ${alias} whose ${why}. ` +
|
|
168
|
-
`Its requirements need {
|
|
182
|
+
`Its requirements need the scope { on: ${c.key}, operations: ['${operation}'] }.`);
|
|
169
183
|
}
|
|
170
184
|
/**
|
|
171
185
|
* Whether a read for the caller may `operation` a Class as the Domain's own read may: its rule
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { DeclaredClass } from '../crossings.js';
|
|
2
|
+
/**
|
|
3
|
+
* @deprecated The legacy `classes` requirements as the Classes a Query may cross (L-SDK-3).
|
|
4
|
+
* Replaced by the Class scopes `declaredClasses` reads. Removal: in the SDK major that adopts a
|
|
5
|
+
* Kernel cohort no longer admitting the legacy capability shape (Kernel
|
|
6
|
+
* `LegacyCapabilityRequirements`, A1e).
|
|
7
|
+
*/
|
|
8
|
+
export declare function legacyDeclaredClasses(capabilities: {
|
|
9
|
+
readonly classes?: readonly DeclaredClass[];
|
|
10
|
+
}): readonly DeclaredClass[];
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @deprecated The legacy `classes` requirements as the Classes a Query may cross (L-SDK-3).
|
|
3
|
+
* Replaced by the Class scopes `declaredClasses` reads. Removal: in the SDK major that adopts a
|
|
4
|
+
* Kernel cohort no longer admitting the legacy capability shape (Kernel
|
|
5
|
+
* `LegacyCapabilityRequirements`, A1e).
|
|
6
|
+
*/
|
|
7
|
+
export function legacyDeclaredClasses(capabilities) {
|
|
8
|
+
return capabilities.classes ?? [];
|
|
9
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/** Throw unless every value is distinct: requirements are canonical sets. */
|
|
2
|
+
export declare function unique(values: readonly string[], label: string): void;
|
|
3
|
+
/** Compare two strings in code-unit order, the order the Kernel admits requirements in. */
|
|
4
|
+
export declare function compare(left: string, right: string): number;
|
|
5
|
+
/** A frozen copy of the values, sorted by their key in code-unit order. */
|
|
6
|
+
export declare function sortedBy<Value>(values: readonly Value[], key: (value: Value) => string): readonly Value[];
|
|
7
|
+
export declare function isRecord(input: unknown): input is Readonly<Record<PropertyKey, unknown>>;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/** Throw unless every value is distinct: requirements are canonical sets. */
|
|
2
|
+
export function unique(values, label) {
|
|
3
|
+
if (new Set(values).size !== values.length)
|
|
4
|
+
throw new TypeError(`${label}s must be unique.`);
|
|
5
|
+
}
|
|
6
|
+
/** Compare two strings in code-unit order, the order the Kernel admits requirements in. */
|
|
7
|
+
export function compare(left, right) {
|
|
8
|
+
return left < right ? -1 : left > right ? 1 : 0;
|
|
9
|
+
}
|
|
10
|
+
/** A frozen copy of the values, sorted by their key in code-unit order. */
|
|
11
|
+
export function sortedBy(values, key) {
|
|
12
|
+
return Object.freeze([...values].sort((left, right) => compare(key(left), key(right))));
|
|
13
|
+
}
|
|
14
|
+
export function isRecord(input) {
|
|
15
|
+
return input !== null && typeof input === 'object' && !Array.isArray(input);
|
|
16
|
+
}
|
|
@@ -1,9 +1,11 @@
|
|
|
1
|
-
import type { AnyResolvedClass } from '../../platform/schema/index.js';
|
|
2
|
-
import type { ClassRequirement } from './requirement.js';
|
|
1
|
+
import type { AnyResolvedClass, ClassRef } from '../../platform/schema/index.js';
|
|
3
2
|
export declare const ClassOperationOrder: readonly ["create", "read", "traverse", "update", "delete"];
|
|
4
3
|
export type ClassOperation = (typeof ClassOperationOrder)[number];
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
4
|
+
/** A Class a requirement names: a resolved Class, or its reference. */
|
|
5
|
+
export type ClassTarget = Pick<AnyResolvedClass, 'ref'> | ClassRef;
|
|
6
|
+
/** Accept the reference of a resolved Class (`{ ref }`) or a Class reference itself. */
|
|
7
|
+
export declare function captureClassRef(input: unknown, message: string): ClassRef;
|
|
8
|
+
/** Whether the input names a Class, resolved or by reference. */
|
|
9
|
+
export declare function namesClass(input: unknown): boolean;
|
|
10
|
+
/** Capture a non-empty set of Class operations in their canonical order. */
|
|
11
|
+
export declare function captureClassOperations(input: unknown, label: string): readonly [ClassOperation, ...ClassOperation[]];
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { acceptDefinitionRef
|
|
1
|
+
import { acceptDefinitionRef } from '../../platform/schema/index.js';
|
|
2
|
+
import { isRecord, unique } from './canonical.js';
|
|
2
3
|
export const ClassOperationOrder = Object.freeze([
|
|
3
4
|
'create',
|
|
4
5
|
'read',
|
|
@@ -6,47 +7,39 @@ export const ClassOperationOrder = Object.freeze([
|
|
|
6
7
|
'update',
|
|
7
8
|
'delete',
|
|
8
9
|
]);
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
const admitted = acceptDefinitionRef(entry.class?.ref);
|
|
21
|
-
if (admitted.kind !== 'class')
|
|
22
|
-
throw new TypeError('Expected Class reference.');
|
|
23
|
-
ref = admitted;
|
|
24
|
-
}
|
|
25
|
-
catch (cause) {
|
|
26
|
-
throw new TypeError('Class requirement target is invalid.', { cause });
|
|
27
|
-
}
|
|
28
|
-
if (entry.operations.length === 0) {
|
|
29
|
-
throw new TypeError('Class requirement operations cannot be empty.');
|
|
30
|
-
}
|
|
31
|
-
const operations = entry.operations.map((operation) => {
|
|
32
|
-
if (!ClassOperationOrder.includes(operation)) {
|
|
33
|
-
throw new TypeError(`Unknown Class requirement operation ${String(operation)}.`);
|
|
34
|
-
}
|
|
35
|
-
return operation;
|
|
36
|
-
});
|
|
37
|
-
unique(operations, 'Class requirement operation');
|
|
38
|
-
return Object.freeze({
|
|
39
|
-
class: ref,
|
|
40
|
-
operations: Object.freeze([...operations].sort((left, right) => ClassOperationOrder.indexOf(left) - ClassOperationOrder.indexOf(right))),
|
|
41
|
-
});
|
|
42
|
-
});
|
|
43
|
-
unique(classes.map((entry) => Key.of(entry.class)), 'Class requirement');
|
|
44
|
-
return Object.freeze([...classes].sort((left, right) => compare(Key.of(left.class), Key.of(right.class))));
|
|
10
|
+
/** Accept the reference of a resolved Class (`{ ref }`) or a Class reference itself. */
|
|
11
|
+
export function captureClassRef(input, message) {
|
|
12
|
+
try {
|
|
13
|
+
const admitted = acceptDefinitionRef(isRecord(input) && 'ref' in input ? input.ref : input);
|
|
14
|
+
if (admitted.kind !== 'class')
|
|
15
|
+
throw new TypeError('Expected Class reference.');
|
|
16
|
+
return admitted;
|
|
17
|
+
}
|
|
18
|
+
catch (cause) {
|
|
19
|
+
throw new TypeError(message, { cause });
|
|
20
|
+
}
|
|
45
21
|
}
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
22
|
+
/** Whether the input names a Class, resolved or by reference. */
|
|
23
|
+
export function namesClass(input) {
|
|
24
|
+
try {
|
|
25
|
+
return (acceptDefinitionRef(isRecord(input) && 'ref' in input ? input.ref : input).kind === 'class');
|
|
26
|
+
}
|
|
27
|
+
catch {
|
|
28
|
+
return false;
|
|
29
|
+
}
|
|
49
30
|
}
|
|
50
|
-
|
|
51
|
-
|
|
31
|
+
/** Capture a non-empty set of Class operations in their canonical order. */
|
|
32
|
+
export function captureClassOperations(input, label) {
|
|
33
|
+
if (!Array.isArray(input))
|
|
34
|
+
throw new TypeError(`${label}s must be an array.`);
|
|
35
|
+
if (input.length === 0)
|
|
36
|
+
throw new TypeError(`${label}s cannot be empty.`);
|
|
37
|
+
for (const operation of input) {
|
|
38
|
+
if (!ClassOperationOrder.includes(operation)) {
|
|
39
|
+
throw new TypeError(`Unknown ${label} ${String(operation)}.`);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
const operations = input;
|
|
43
|
+
unique(operations, label);
|
|
44
|
+
return Object.freeze([...operations].sort((left, right) => ClassOperationOrder.indexOf(left) - ClassOperationOrder.indexOf(right)));
|
|
52
45
|
}
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import type { ResolvedFunction, ResolvedMethod } from '../../platform/schema/index.js';
|
|
2
2
|
import type { Key as SemanticKey } from '../../platform/schema/index.js';
|
|
3
|
+
/** A Function or Method a requirement names, by its resolved definition. */
|
|
3
4
|
export type FunctionRequirementTarget = Pick<ResolvedFunction, 'key'> | Pick<ResolvedMethod, 'key'>;
|
|
4
|
-
|
|
5
|
+
/** Accept the exact Key of one Function or Method. */
|
|
6
|
+
export declare function captureCallable(input: unknown, message: string): SemanticKey.Callable;
|
|
@@ -1,30 +1,15 @@
|
|
|
1
1
|
import { callableAddress, Key } from '../../platform/schema/index.js';
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
if (!
|
|
6
|
-
throw new TypeError(
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
}
|
|
11
|
-
let key;
|
|
12
|
-
try {
|
|
13
|
-
key = Key(target.key);
|
|
14
|
-
callableAddress(key);
|
|
15
|
-
}
|
|
16
|
-
catch (cause) {
|
|
17
|
-
throw new TypeError('Function requirement target is invalid.', { cause });
|
|
18
|
-
}
|
|
2
|
+
import { isRecord } from './canonical.js';
|
|
3
|
+
/** Accept the exact Key of one Function or Method. */
|
|
4
|
+
export function captureCallable(input, message) {
|
|
5
|
+
if (!isRecord(input) || typeof input.key !== 'string')
|
|
6
|
+
throw new TypeError(message);
|
|
7
|
+
try {
|
|
8
|
+
const key = Key(input.key);
|
|
9
|
+
callableAddress(key);
|
|
19
10
|
return key;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
}
|
|
24
|
-
function unique(values, label) {
|
|
25
|
-
if (new Set(values).size !== values.length)
|
|
26
|
-
throw new TypeError(`${label}s must be unique.`);
|
|
27
|
-
}
|
|
28
|
-
function compare(left, right) {
|
|
29
|
-
return left < right ? -1 : left > right ? 1 : 0;
|
|
11
|
+
}
|
|
12
|
+
catch (cause) {
|
|
13
|
+
throw new TypeError(message, { cause });
|
|
14
|
+
}
|
|
30
15
|
}
|
|
@@ -1,19 +1,37 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type {
|
|
3
|
-
import type {
|
|
4
|
-
import type {
|
|
5
|
-
|
|
6
|
-
export
|
|
7
|
-
export { ClassOperationOrder, type ClassOperation, type ClassRequirementInput } from './classes.js';
|
|
1
|
+
import type { LegacyRequirements, LegacyRequirementsInput } from './legacy/index.js';
|
|
2
|
+
import type { DomainHolder, RoleRequirements } from './requirement.js';
|
|
3
|
+
import type { RoleRequirementInput } from './roles.js';
|
|
4
|
+
import type { ScopeRequirementInput } from './scopes.js';
|
|
5
|
+
export type { CallableScopeRequirement, ClassScopeRequirement, DomainHolder, RequirementHolder, RoleRequirement, RoleRequirements, ScopeRequirement, } from './requirement.js';
|
|
6
|
+
export { ClassOperationOrder, type ClassOperation, type ClassTarget } from './classes.js';
|
|
8
7
|
export type { FunctionRequirementTarget } from './functions.js';
|
|
9
|
-
export type {
|
|
10
|
-
export type {
|
|
11
|
-
export
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
readonly
|
|
15
|
-
readonly
|
|
8
|
+
export type { CoreNodeInput, HolderInput, RoleRequirementInput } from './roles.js';
|
|
9
|
+
export type { CallableScopeRequirementInput, ClassScopeRequirementInput, ScopeRequirementInput, } from './scopes.js';
|
|
10
|
+
export type { AuthorityRequirements, AuthorityRequirementsInput, ClassRequirement, ClassRequirementInput, CoreRequirement, CoreRequirementInput, LegacyAuthorityRequirements, LegacyAuthorityRequirementsInput, LegacyClassRequirement, LegacyClassRequirementInput, LegacyCoreRequirement, LegacyCoreRequirementInput, LegacyRequirements, LegacyRequirementsInput, } from './legacy/index.js';
|
|
11
|
+
/** The Kernel Roles a release binds and the scopes its installed Domain holds. */
|
|
12
|
+
export interface RoleRequirementsInput {
|
|
13
|
+
readonly roles?: readonly RoleRequirementInput[];
|
|
14
|
+
readonly scopes?: readonly ScopeRequirementInput[];
|
|
16
15
|
}
|
|
17
|
-
/**
|
|
18
|
-
export
|
|
16
|
+
/** Everything `requirements` accepts: Roles and scopes, or the legacy shape (L-SDK-1). */
|
|
17
|
+
export type RequirementsInput = RoleRequirementsInput | LegacyRequirementsInput;
|
|
18
|
+
/** A captured requirement set: Roles and scopes, or the legacy shape (L-SDK-1). */
|
|
19
|
+
export type Requirements = RoleRequirements | LegacyRequirements;
|
|
20
|
+
export interface RequirementsFunction {
|
|
21
|
+
/**
|
|
22
|
+
* Capture the Kernel Roles and scopes a Domain release requires, canonical and frozen. Build
|
|
23
|
+
* proves them against the exact dependency closure.
|
|
24
|
+
*/
|
|
25
|
+
(input?: RoleRequirementsInput): RoleRequirements;
|
|
26
|
+
/**
|
|
27
|
+
* @deprecated The capability shape of a release before Kernel Roles (L-SDK-1). Replaced by
|
|
28
|
+
* `requirements({ roles, scopes })`. Removal: in the SDK major that adopts a Kernel cohort no
|
|
29
|
+
* longer admitting the legacy capability shape (Kernel `LegacyCapabilityRequirements`, A1e).
|
|
30
|
+
*/
|
|
31
|
+
(input: LegacyRequirementsInput): LegacyRequirements;
|
|
32
|
+
/** The installed Domain as a Role member or granter: `{ kind: 'domain' }`. */
|
|
33
|
+
readonly domain: DomainHolder;
|
|
34
|
+
}
|
|
35
|
+
/** Capture canonical Role and scope requirements; Build proves the pinned dependency closure. */
|
|
36
|
+
export declare const requirements: RequirementsFunction;
|
|
19
37
|
export declare function isRequirements(input: unknown): input is Requirements;
|
|
@@ -1,32 +1,29 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
1
|
+
import { isLegacyCapabilities } from '@astrale-os/kernel-protocol/release';
|
|
2
|
+
import { legacyRequirements } from './legacy/index.js';
|
|
3
|
+
import { captureRoles, DOMAIN_HOLDER } from './roles.js';
|
|
4
|
+
import { captureScopes } from './scopes.js';
|
|
5
5
|
export { ClassOperationOrder } from './classes.js';
|
|
6
6
|
const admittedRequirements = new WeakSet();
|
|
7
|
-
|
|
8
|
-
export function requirements(input = {}) {
|
|
7
|
+
function capture(input = {}) {
|
|
9
8
|
if (input === null || typeof input !== 'object' || Array.isArray(input))
|
|
10
9
|
invalid();
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
const classes = captureClasses(input.classes);
|
|
16
|
-
const authority = captureAuthority(input.authority);
|
|
17
|
-
const core = captureCore(input.core);
|
|
18
|
-
const value = Object.freeze({
|
|
19
|
-
functions,
|
|
20
|
-
classes,
|
|
21
|
-
core,
|
|
22
|
-
...(authority === undefined ? {} : { authority }),
|
|
23
|
-
});
|
|
10
|
+
// The one seam to the legacy shape: a key only that shape declares selects it.
|
|
11
|
+
const value = isLegacyCapabilities(input)
|
|
12
|
+
? legacyRequirements(input)
|
|
13
|
+
: captureRoleRequirements(input);
|
|
24
14
|
admittedRequirements.add(value);
|
|
25
15
|
return value;
|
|
26
16
|
}
|
|
17
|
+
/** Capture canonical Role and scope requirements; Build proves the pinned dependency closure. */
|
|
18
|
+
export const requirements = Object.freeze(Object.assign(capture, { domain: DOMAIN_HOLDER }));
|
|
27
19
|
export function isRequirements(input) {
|
|
28
20
|
return input !== null && typeof input === 'object' && admittedRequirements.has(input);
|
|
29
21
|
}
|
|
22
|
+
function captureRoleRequirements(input) {
|
|
23
|
+
if (Reflect.ownKeys(input).some((key) => key !== 'roles' && key !== 'scopes'))
|
|
24
|
+
invalid();
|
|
25
|
+
return Object.freeze({ roles: captureRoles(input.roles), scopes: captureScopes(input.scopes) });
|
|
26
|
+
}
|
|
30
27
|
function invalid() {
|
|
31
|
-
throw new TypeError('Requirements definition may contain only
|
|
28
|
+
throw new TypeError('Requirements definition may contain only roles and scopes.');
|
|
32
29
|
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { AuthorityOperation } from '../../../platform/schema/index.js';
|
|
2
|
+
/**
|
|
3
|
+
* @deprecated Authority operations the installed Domain may grant or revoke, by Operation
|
|
4
|
+
* (L-SDK-1). Replaced by `granters` of a `RoleRequirementInput`. Removal: in the SDK major that adopts a Kernel cohort no longer admitting the legacy capability shape (Kernel `LegacyCapabilityRequirements`, A1e).
|
|
5
|
+
*/
|
|
6
|
+
export interface LegacyAuthorityRequirementsInput {
|
|
7
|
+
readonly grant?: readonly [AuthorityOperation, ...AuthorityOperation[]];
|
|
8
|
+
readonly revoke?: readonly [AuthorityOperation, ...AuthorityOperation[]];
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* @deprecated The captured grant and revoke operations (L-SDK-1). Replaced by `RoleRequirement`
|
|
12
|
+
* granters. Removal: in the SDK major that adopts a Kernel cohort no longer admitting the legacy capability shape (Kernel `LegacyCapabilityRequirements`, A1e).
|
|
13
|
+
*/
|
|
14
|
+
export interface LegacyAuthorityRequirements {
|
|
15
|
+
readonly grant?: readonly [AuthorityOperation, ...AuthorityOperation[]];
|
|
16
|
+
readonly revoke?: readonly [AuthorityOperation, ...AuthorityOperation[]];
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* @deprecated Capture legacy authority operations (L-SDK-1). Replaced by `captureRoles`. Removal: in the SDK major that adopts a Kernel cohort no longer admitting the legacy capability shape (Kernel `LegacyCapabilityRequirements`, A1e).
|
|
20
|
+
*/
|
|
21
|
+
export declare function legacyAuthority(input: LegacyAuthorityRequirementsInput | undefined): LegacyAuthorityRequirements | undefined;
|
|
@@ -1,5 +1,8 @@
|
|
|
1
|
-
import { AuthorityOperationOrder } from '
|
|
2
|
-
|
|
1
|
+
import { AuthorityOperationOrder } from '../../../platform/schema/index.js';
|
|
2
|
+
/**
|
|
3
|
+
* @deprecated Capture legacy authority operations (L-SDK-1). Replaced by `captureRoles`. Removal: in the SDK major that adopts a Kernel cohort no longer admitting the legacy capability shape (Kernel `LegacyCapabilityRequirements`, A1e).
|
|
4
|
+
*/
|
|
5
|
+
export function legacyAuthority(input) {
|
|
3
6
|
if (input === undefined)
|
|
4
7
|
return undefined;
|
|
5
8
|
if (input === null || typeof input !== 'object' || Array.isArray(input))
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { AnyResolvedClass, ClassRef } from '../../../platform/schema/index.js';
|
|
2
|
+
import type { ClassOperation } from '../classes.js';
|
|
3
|
+
/**
|
|
4
|
+
* @deprecated Class operations the installed Domain holds on a Class, by `class` (L-SDK-1).
|
|
5
|
+
* Replaced by `ClassScopeRequirementInput` (`{ on, operations }` in `scopes`). Removal: in the SDK major that adopts a Kernel cohort no longer admitting the legacy capability shape (Kernel `LegacyCapabilityRequirements`, A1e).
|
|
6
|
+
*/
|
|
7
|
+
export interface LegacyClassRequirementInput {
|
|
8
|
+
readonly class: Pick<AnyResolvedClass, 'ref'>;
|
|
9
|
+
readonly operations: readonly [ClassOperation, ...ClassOperation[]];
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* @deprecated A captured legacy Class requirement (L-SDK-1). Replaced by
|
|
13
|
+
* `ClassScopeRequirement`. Removal: in the SDK major that adopts a Kernel cohort no longer admitting the legacy capability shape (Kernel `LegacyCapabilityRequirements`, A1e).
|
|
14
|
+
*/
|
|
15
|
+
export interface LegacyClassRequirement {
|
|
16
|
+
readonly class: ClassRef;
|
|
17
|
+
readonly operations: readonly [ClassOperation, ...ClassOperation[]];
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* @deprecated Capture legacy Class requirements (L-SDK-1). Replaced by `captureScopes`. Removal: in the SDK major that adopts a Kernel cohort no longer admitting the legacy capability shape (Kernel `LegacyCapabilityRequirements`, A1e).
|
|
21
|
+
*/
|
|
22
|
+
export declare function legacyClasses(input: readonly LegacyClassRequirementInput[] | undefined): readonly LegacyClassRequirement[];
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { Key } from '../../../platform/schema/index.js';
|
|
2
|
+
import { sortedBy, unique } from '../canonical.js';
|
|
3
|
+
import { captureClassOperations, captureClassRef } from '../classes.js';
|
|
4
|
+
/**
|
|
5
|
+
* @deprecated Capture legacy Class requirements (L-SDK-1). Replaced by `captureScopes`. Removal: in the SDK major that adopts a Kernel cohort no longer admitting the legacy capability shape (Kernel `LegacyCapabilityRequirements`, A1e).
|
|
6
|
+
*/
|
|
7
|
+
export function legacyClasses(input) {
|
|
8
|
+
if (input === undefined)
|
|
9
|
+
return Object.freeze([]);
|
|
10
|
+
if (!Array.isArray(input))
|
|
11
|
+
throw new TypeError('Requirement classes must be an array.');
|
|
12
|
+
const classes = input.map((entry) => {
|
|
13
|
+
if (entry === null || typeof entry !== 'object' || !Array.isArray(entry.operations)) {
|
|
14
|
+
throw new TypeError('Class requirement is invalid.');
|
|
15
|
+
}
|
|
16
|
+
const ref = captureClassRef(entry.class?.ref, 'Class requirement target is invalid.');
|
|
17
|
+
return Object.freeze({
|
|
18
|
+
class: ref,
|
|
19
|
+
operations: captureClassOperations(entry.operations, 'Class requirement operation'),
|
|
20
|
+
});
|
|
21
|
+
});
|
|
22
|
+
unique(classes.map((entry) => Key.of(entry.class)), 'Class requirement');
|
|
23
|
+
return sortedBy(classes, (entry) => Key.of(entry.class));
|
|
24
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { CoreRef, Key, ResolvedCoreDefinition } from '../../../platform/schema/index.js';
|
|
2
|
+
import type { FunctionRequirementTarget } from '../functions.js';
|
|
3
|
+
import type { LegacyAuthorityRequirements, LegacyAuthorityRequirementsInput } from './authority.js';
|
|
4
|
+
import type { LegacyClassRequirement, LegacyClassRequirementInput } from './classes.js';
|
|
5
|
+
/**
|
|
6
|
+
* @deprecated Capabilities assigned to one installation-owned local Core Identity (L-SDK-1).
|
|
7
|
+
* Replaced by a `RoleRequirementInput` whose `members` name that Core Identity. Removal: in the SDK major that adopts a Kernel cohort no longer admitting the legacy capability shape (Kernel `LegacyCapabilityRequirements`, A1e).
|
|
8
|
+
*/
|
|
9
|
+
export interface LegacyCoreRequirementInput {
|
|
10
|
+
readonly subject: Pick<ResolvedCoreDefinition, 'ref'>;
|
|
11
|
+
/** Exact executable local callables or direct dependency callables; does not bypass Policies. */
|
|
12
|
+
readonly functions?: readonly FunctionRequirementTarget[];
|
|
13
|
+
readonly classes?: readonly LegacyClassRequirementInput[];
|
|
14
|
+
readonly authority?: LegacyAuthorityRequirementsInput;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* @deprecated Capabilities assigned at installation to one Identity declared in the local Core
|
|
18
|
+
* (L-SDK-1). Replaced by `RoleRequirement`. Removal: in the SDK major that adopts a Kernel cohort no longer admitting the legacy capability shape (Kernel `LegacyCapabilityRequirements`, A1e).
|
|
19
|
+
*/
|
|
20
|
+
export interface LegacyCoreRequirement {
|
|
21
|
+
readonly subject: CoreRef;
|
|
22
|
+
readonly functions: readonly Key.Callable[];
|
|
23
|
+
readonly classes: readonly LegacyClassRequirement[];
|
|
24
|
+
readonly authority?: LegacyAuthorityRequirements;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* @deprecated Capture legacy Core Identity requirements (L-SDK-1). Replaced by `captureRoles`.
|
|
28
|
+
* Removal: in the SDK major that adopts a Kernel cohort no longer admitting the legacy capability shape (Kernel `LegacyCapabilityRequirements`, A1e).
|
|
29
|
+
*/
|
|
30
|
+
export declare function legacyCore(input: readonly LegacyCoreRequirementInput[] | undefined): readonly LegacyCoreRequirement[];
|
|
@@ -1,8 +1,13 @@
|
|
|
1
|
-
import { acceptDefinitionRef, Key } from '
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
|
|
1
|
+
import { acceptDefinitionRef, Key as SemanticKey } from '../../../platform/schema/index.js';
|
|
2
|
+
import { sortedBy } from '../canonical.js';
|
|
3
|
+
import { legacyAuthority } from './authority.js';
|
|
4
|
+
import { legacyClasses } from './classes.js';
|
|
5
|
+
import { legacyFunctions } from './functions.js';
|
|
6
|
+
/**
|
|
7
|
+
* @deprecated Capture legacy Core Identity requirements (L-SDK-1). Replaced by `captureRoles`.
|
|
8
|
+
* Removal: in the SDK major that adopts a Kernel cohort no longer admitting the legacy capability shape (Kernel `LegacyCapabilityRequirements`, A1e).
|
|
9
|
+
*/
|
|
10
|
+
export function legacyCore(input) {
|
|
6
11
|
if (input === undefined)
|
|
7
12
|
return Object.freeze([]);
|
|
8
13
|
if (!Array.isArray(input))
|
|
@@ -17,9 +22,9 @@ export function captureCore(input) {
|
|
|
17
22
|
if (admitted.kind !== 'core')
|
|
18
23
|
invalid();
|
|
19
24
|
const subject = admitted;
|
|
20
|
-
const functions =
|
|
21
|
-
const classes =
|
|
22
|
-
const authority =
|
|
25
|
+
const functions = legacyFunctions(entry.functions);
|
|
26
|
+
const classes = legacyClasses(entry.classes);
|
|
27
|
+
const authority = legacyAuthority(entry.authority);
|
|
23
28
|
if (functions.length === 0 && classes.length === 0 && authority === undefined)
|
|
24
29
|
invalid();
|
|
25
30
|
return Object.freeze({
|
|
@@ -29,13 +34,10 @@ export function captureCore(input) {
|
|
|
29
34
|
...(authority === undefined ? {} : { authority }),
|
|
30
35
|
});
|
|
31
36
|
});
|
|
32
|
-
if (new Set(core.map(({ subject }) =>
|
|
37
|
+
if (new Set(core.map(({ subject }) => SemanticKey.of(subject))).size !== core.length)
|
|
33
38
|
invalid();
|
|
34
|
-
return
|
|
39
|
+
return sortedBy(core, ({ subject }) => SemanticKey.of(subject));
|
|
35
40
|
}
|
|
36
41
|
function invalid() {
|
|
37
42
|
throw new TypeError('Core capability requirement is invalid.');
|
|
38
43
|
}
|
|
39
|
-
function compare(left, right) {
|
|
40
|
-
return left < right ? -1 : left > right ? 1 : 0;
|
|
41
|
-
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { Key as SemanticKey } from '../../../platform/schema/index.js';
|
|
2
|
+
import type { FunctionRequirementTarget } from '../functions.js';
|
|
3
|
+
/**
|
|
4
|
+
* @deprecated Capture the legacy `functions` list the installed Domain may call (L-SDK-1).
|
|
5
|
+
* Replaced by `captureScopes` over `CallableScopeRequirementInput`. Removal: in the SDK major that adopts a Kernel cohort no longer admitting the legacy capability shape (Kernel `LegacyCapabilityRequirements`, A1e).
|
|
6
|
+
*/
|
|
7
|
+
export declare function legacyFunctions(input: readonly FunctionRequirementTarget[] | undefined): readonly SemanticKey.Callable[];
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { compare, unique } from '../canonical.js';
|
|
2
|
+
import { captureCallable } from '../functions.js';
|
|
3
|
+
/**
|
|
4
|
+
* @deprecated Capture the legacy `functions` list the installed Domain may call (L-SDK-1).
|
|
5
|
+
* Replaced by `captureScopes` over `CallableScopeRequirementInput`. Removal: in the SDK major that adopts a Kernel cohort no longer admitting the legacy capability shape (Kernel `LegacyCapabilityRequirements`, A1e).
|
|
6
|
+
*/
|
|
7
|
+
export function legacyFunctions(input) {
|
|
8
|
+
if (input === undefined)
|
|
9
|
+
return Object.freeze([]);
|
|
10
|
+
if (!Array.isArray(input))
|
|
11
|
+
throw new TypeError('Requirement functions must be an array.');
|
|
12
|
+
const keys = input.map((target) => captureCallable(target, 'Function requirement target is invalid.'));
|
|
13
|
+
unique(keys, 'Function requirement');
|
|
14
|
+
return Object.freeze([...keys].sort(compare));
|
|
15
|
+
}
|