@astrale-os/kernel-core 0.9.0-beta.30 → 0.9.0-beta.31

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.
@@ -4,6 +4,7 @@ export declare const limits: {
4
4
  readonly expressionDepth: 64;
5
5
  readonly operandsPerExpression: 512;
6
6
  readonly localsPerExpression: 64;
7
+ readonly classesPerLocal: 1024;
7
8
  readonly repeatMaximum: 16;
8
9
  };
9
10
  export declare const MAX_BOOLEAN_OPERANDS: 512;
@@ -6,6 +6,7 @@ export const limits = Object.freeze({
6
6
  expressionDepth: 64,
7
7
  operandsPerExpression: 512,
8
8
  localsPerExpression: 64,
9
+ classesPerLocal: 1024,
9
10
  repeatMaximum: 16,
10
11
  });
11
12
  export const MAX_BOOLEAN_OPERANDS = limits.operandsPerExpression;
@@ -139,8 +140,21 @@ function term(input, path, locals, subjectBound) {
139
140
  }
140
141
  function localDeclaration(input, path) {
141
142
  const value = record(input, path);
142
- exact(value, ['class', 'id'], path);
143
- return { id: localId(value.id, `${path}/id`), class: nodeClassRef(value.class, `${path}/class`) };
143
+ const id = localId(value.id, `${path}/id`);
144
+ if (value.kind === 'any') {
145
+ exact(value, ['id', 'kind'], path);
146
+ return { id, kind: 'any' };
147
+ }
148
+ if (value.kind === 'classes') {
149
+ exact(value, ['classes', 'id', 'kind'], path);
150
+ const classes = array(value.classes, `${path}/classes`, 1, limits.classesPerLocal).map((entry, index) => nodeClassRef(entry, `${path}/classes/${index}`));
151
+ return {
152
+ id,
153
+ kind: 'classes',
154
+ classes: classes,
155
+ };
156
+ }
157
+ invalid(`${path}/kind`, 'Expected any or classes local selector');
144
158
  }
145
159
  function repeat(input, path) {
146
160
  const value = record(input, path);
@@ -1,7 +1,7 @@
1
1
  import type { ClassRef, CoreRef, Key } from '@astrale-os/kernel-dsl/v1/addressing';
2
2
  import type { NodeId } from '../../../graph/node/index.js';
3
3
  import type { Grant } from '../../grant/index.js';
4
- export declare const AUTHORITY_PREDICATE_VERSION: 6;
4
+ export declare const AUTHORITY_PREDICATE_VERSION: 7;
5
5
  export type Operation = 'create' | 'read' | 'traverse' | 'update' | 'delete';
6
6
  export type Input = 'object' | 'source' | 'target';
7
7
  export type { ClassRef } from '@astrale-os/kernel-dsl/v1/addressing';
@@ -30,10 +30,14 @@ export interface Repeat {
30
30
  readonly min: number;
31
31
  readonly max: number;
32
32
  }
33
- export interface LocalDeclaration {
33
+ export type LocalDeclaration = {
34
34
  readonly id: number;
35
- readonly class: ClassRef;
36
- }
35
+ readonly kind: 'any';
36
+ } | {
37
+ readonly id: number;
38
+ readonly kind: 'classes';
39
+ readonly classes: readonly [ClassRef, ...ClassRef[]];
40
+ };
37
41
  export interface Requirement {
38
42
  readonly op: 'class-authority';
39
43
  readonly identity: Term;
@@ -1 +1 @@
1
- export const AUTHORITY_PREDICATE_VERSION = 6;
1
+ export const AUTHORITY_PREDICATE_VERSION = 7;
@@ -122,7 +122,17 @@ function normalizeTerm(term) {
122
122
  }
123
123
  }
124
124
  function normalizeLocal(local) {
125
- return Object.freeze({ id: local.id, class: Object.freeze({ ...local.class }) });
125
+ if (local.kind === 'any')
126
+ return Object.freeze({ id: local.id, kind: 'any' });
127
+ const classes = new Map(local.classes.map((ref) => [classKey(ref), Object.freeze({ ...ref })]));
128
+ return Object.freeze({
129
+ id: local.id,
130
+ kind: 'classes',
131
+ classes: Object.freeze([...classes.entries()].sort(([left], [right]) => compare(left, right)).map(([, ref]) => ref)),
132
+ });
133
+ }
134
+ function classKey(ref) {
135
+ return `${ref.origin}:${ref.kind}.${ref.name}`;
126
136
  }
127
137
  function compare(left, right) {
128
138
  return left < right ? -1 : left > right ? 1 : 0;