@astrale-os/kernel-dsl 1.0.0-beta.28 → 1.0.0-beta.29
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/dist/v1/builder/schema/projection/identity.d.ts +15 -0
- package/dist/v1/builder/schema/projection/property.d.ts +3 -3
- package/dist/v1/builder/schema/projection/resolved-class.d.ts +3 -3
- package/dist/v1/domain/namespace/member-collection.js +4 -1
- package/dist/v1/language/class/resolved.d.ts +9 -4
- package/dist/v1/language/value/model/blob.d.ts +6 -0
- package/dist/v1/language/value/model/blob.js +8 -0
- package/dist/v1/schema/enforcement/changes.d.ts +4 -4
- package/dist/v1/schema/enforcement/changes.js +4 -4
- package/dist/v1/schema/validation/value-api.d.ts +1 -1
- package/dist/v1/schema/validation/value-api.js +1 -1
- package/dist/value/accept.d.ts +6 -0
- package/dist/value/accept.js +25 -1
- package/dist/value/immutable.optimization.d.ts +2 -0
- package/dist/value/immutable.optimization.js +4 -0
- package/dist/value/index.d.ts +1 -1
- package/dist/value/index.js +1 -1
- package/package.json +1 -1
|
@@ -35,6 +35,21 @@ type LocalNameOfOwner<Root extends DomainSchemaInput, Value> = {
|
|
|
35
35
|
type UnionIsMultiple<Value, Whole = Value> = Value extends unknown ? [Whole] extends [Value] ? false : true : never;
|
|
36
36
|
/** Distinguish ambiguous unions from one exact member. */
|
|
37
37
|
export type IsMultiple<Value> = true extends UnionIsMultiple<Value> ? true : false;
|
|
38
|
+
type ParentsAmong<Root extends DomainSchemaInput, Parents, Owners> = Parents extends readonly [
|
|
39
|
+
infer Parent,
|
|
40
|
+
...infer Rest
|
|
41
|
+
] ? [Extract<LocalNameOfReference<Root, ResolveLazy<Parent>>, Owners>] extends [never] ? ParentsAmong<Root, Rest, Owners> : readonly [Parent, ...ParentsAmong<Root, Rest, Owners>] : readonly [];
|
|
42
|
+
type AncestorHoldsOwnersApart<Root extends DomainSchemaInput, Parent, Owners, Seen> = Exclude<LocalNameOfReference<Root, ResolveLazy<Parent>>, Seen> extends infer Name ? Name extends keyof ClassesInputOf<Root> ? HoldsOwnersApart<Root, ClassesInputOf<Root>[Name], Owners, Seen | Name> : never : never;
|
|
43
|
+
/** Whether two parents of the Class, or of a Class it extends, are among the candidate owners. */
|
|
44
|
+
type HoldsOwnersApart<Root extends DomainSchemaInput, Value, Owners, Seen = never> = ClassInputOf<Value> extends {
|
|
45
|
+
readonly extends: infer Parents extends readonly unknown[];
|
|
46
|
+
} ? ParentsAmong<Root, Parents, Owners>['length'] extends 0 | 1 ? true extends AncestorHoldsOwnersApart<Root, Parents[number], Owners, Seen> ? true : false : true : false;
|
|
47
|
+
/**
|
|
48
|
+
* The candidate owners of each Property an inherited member is on the Class. Classes alike in shape
|
|
49
|
+
* are one owner to the types: from one parent among them the Class has one Property, declared by
|
|
50
|
+
* one of them; from two parents among them, each has a Property of its own.
|
|
51
|
+
*/
|
|
52
|
+
export type OwnersOfEachProperty<Root extends DomainSchemaInput, Value, Owners> = IsMultiple<Owners> extends true ? HoldsOwnersApart<Root, Value, Owners> extends true ? Owners extends unknown ? readonly [Owners] : never : readonly [Owners] : readonly [Owners];
|
|
38
53
|
/** Recover the local declaring Class name for an effective member. */
|
|
39
54
|
export type OwnerNameOf<Root extends DomainSchemaInput, CurrentName extends string, Owner> = Owner extends 'self' ? CurrentName : Owner extends ClassOwnerProjection ? Extract<LocalNameOfOwner<Root, Owner>, string> : Owner extends ClassIdentityProjection ? Extract<LocalNameOfIdentity<Root, Owner>, string> : never;
|
|
40
55
|
export {};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type * as language from '../../../language/index.js';
|
|
2
2
|
import type { AuthoredPropertyProjection } from '../../class/projection.js';
|
|
3
3
|
import type { DomainSchemaInput } from '../input.js';
|
|
4
|
-
import type { RecordField, ClassInputOf, OwnerNameOf } from './identity.js';
|
|
4
|
+
import type { RecordField, ClassInputOf, OwnerNameOf, OwnersOfEachProperty } from './identity.js';
|
|
5
5
|
import type { PropertyProjection } from './model.js';
|
|
6
6
|
type PropertyFieldsOf<Value> = RecordField<ClassInputOf<Value>, 'properties'>;
|
|
7
7
|
interface AuthoredPropertyEntry<Owner, Name extends string, Field> {
|
|
@@ -26,7 +26,7 @@ export type OwnPropertyProjectionsOf<Origin extends string, Name extends string,
|
|
|
26
26
|
export type EffectivePropertyEntriesOfClass<Value> = ClassInputOf<Value> extends {
|
|
27
27
|
readonly effectiveProperties: infer Properties;
|
|
28
28
|
} ? Properties : never;
|
|
29
|
-
type EffectivePropertyProjectionOfEntry<Origin extends string, CurrentName extends string, Root extends DomainSchemaInput, Entry> = Entry extends language.ResolvedProperty ? PropertyProjectionOfResolved<Entry> : Entry extends AuthoredPropertyProjection<infer Input, infer Output, infer Required, infer PropertyName, infer Owner, infer State> ? OwnerNameOf<Root, CurrentName, Owner
|
|
29
|
+
type EffectivePropertyProjectionOfEntry<Origin extends string, CurrentName extends string, Value, Root extends DomainSchemaInput, Entry> = Entry extends language.ResolvedProperty ? PropertyProjectionOfResolved<Entry> : Entry extends AuthoredPropertyProjection<infer Input, infer Output, infer Required, infer PropertyName, infer Owner, infer State> ? OwnersOfEachProperty<Root, Value, OwnerNameOf<Root, CurrentName, Owner>> extends infer Owners ? Owners extends readonly [infer OwnerName extends string] ? PropertyProjection<Output, Required, PropertyName, language.PropertyKey<Origin, OwnerName, PropertyName>, State, Input> : never : never : never;
|
|
30
30
|
/** Bind effective Property witnesses to their declaring Class coordinates. */
|
|
31
|
-
export type EffectivePropertyProjectionsOf<Origin extends string, Name extends string, Value, Root extends DomainSchemaInput> = EffectivePropertyEntriesOfClass<Value> extends infer Entry ? Entry extends unknown ? EffectivePropertyProjectionOfEntry<Origin, Name, Root, Entry> : never : never;
|
|
31
|
+
export type EffectivePropertyProjectionsOf<Origin extends string, Name extends string, Value, Root extends DomainSchemaInput> = EffectivePropertyEntriesOfClass<Value> extends infer Entry ? Entry extends unknown ? EffectivePropertyProjectionOfEntry<Origin, Name, Value, Root, Entry> : never : never;
|
|
32
32
|
export {};
|
|
@@ -41,10 +41,10 @@ type ResolvedPropertyOfProjection<Value> = Value extends PropertyProjection<infe
|
|
|
41
41
|
readonly name: Name;
|
|
42
42
|
readonly key: Key;
|
|
43
43
|
} : never;
|
|
44
|
+
type PropertiesBearing<Entries extends PropertyProjection, Key> = Entries extends unknown ? Key extends Entries['key'] ? Entries : never : never;
|
|
45
|
+
/** A Property under each key it may bear: see `OwnersOfEachProperty`. */
|
|
44
46
|
type ProjectionPropertyByKey<Entries extends PropertyProjection> = Readonly<{
|
|
45
|
-
[Key in Entries['key']]: ResolvedPropertyOfProjection<
|
|
46
|
-
readonly key: Key;
|
|
47
|
-
}>>;
|
|
47
|
+
[Key in Entries['key']]: ResolvedPropertyOfProjection<PropertiesBearing<Entries, Key>>;
|
|
48
48
|
}>;
|
|
49
49
|
type ProjectionPropertyByName<Entries extends PropertyProjection> = Readonly<{
|
|
50
50
|
[Name in Entries['name'] as IsMultiple<Extract<Entries, {
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { PropertyKey as PropertyKeyValue } from '../../addressing/index.js';
|
|
2
2
|
import { compareCodeUnits } from '../../addressing/ordering.js';
|
|
3
3
|
import { createPropertyValues } from '../../language/class/property-values.js';
|
|
4
|
+
import { isBlobReceipt, isBlobValueSchema } from '../../language/value/model/blob.js';
|
|
4
5
|
const PROPERTY_OPERATIONS = new Set(['byKey', 'get', 'from']);
|
|
5
6
|
const METHOD_OPERATIONS = new Set(['byKey', 'get']);
|
|
6
7
|
export function createPropertyCollection(values) {
|
|
@@ -23,7 +24,9 @@ export function createPropertyCollection(values) {
|
|
|
23
24
|
if (entries.has(property.key)) {
|
|
24
25
|
throw new TypeError(`Property ${property.key} is supplied through both ${JSON.stringify(source.get(property.key))} and ${JSON.stringify(candidate)}.`);
|
|
25
26
|
}
|
|
26
|
-
|
|
27
|
+
// A receipt stands in for a blob's Ref until a write; only the issuing Kernel can judge it.
|
|
28
|
+
const receipt = isBlobReceipt(value) && isBlobValueSchema(property.definition.schema);
|
|
29
|
+
const diagnostics = receipt ? [] : property.validate(value);
|
|
27
30
|
if (diagnostics.length > 0) {
|
|
28
31
|
throw new TypeError(`Invalid value for Property ${property.key}: ${diagnostics.map(({ message }) => message).join('; ')}`);
|
|
29
32
|
}
|
|
@@ -19,6 +19,7 @@ export interface ResolvedProperty<out Value = PortableValue, out Required extend
|
|
|
19
19
|
};
|
|
20
20
|
/** The one portable scalar ordering domain, when the Property is orderable. */
|
|
21
21
|
readonly ordering?: OrderingKind;
|
|
22
|
+
/** Check a value the Property holds, which a read returns: a `Ref` for a blob. */
|
|
22
23
|
validate(input: unknown): readonly Diagnostic[];
|
|
23
24
|
/** The admitted program `validate` evaluates. */
|
|
24
25
|
program(): ValueProgram;
|
|
@@ -33,7 +34,11 @@ export type ResolvedPropertyCollection<ByKey extends Readonly<Record<PropertyKey
|
|
|
33
34
|
readonly byKey: ByKey;
|
|
34
35
|
get<Key extends keyof ByKey>(key: Key): ByKey[Key];
|
|
35
36
|
get(key: PropertyKey): ResolvedProperty | undefined;
|
|
36
|
-
|
|
37
|
+
/**
|
|
38
|
+
* A set of values by name or key, each checked by `validate`. A blob also takes the text of an
|
|
39
|
+
* upload receipt, which a write exchanges for its Ref and only the issuing Kernel can judge.
|
|
40
|
+
*/
|
|
41
|
+
from(input: PropertyValuesInput<ByKey, ByName>): PropertyValues;
|
|
37
42
|
};
|
|
38
43
|
export interface ResolvedClass<Kind extends ClassKind = ClassKind, Properties extends ResolvedPropertyCollection = ResolvedPropertyCollection, InstanceMethods extends ResolvedMethodCollection = ResolvedMethodCollection, StaticMethods extends ResolvedMethodCollection = ResolvedMethodCollection, SelfProperties extends ResolvedPropertyCollection = ResolvedPropertyCollection, SelfInstanceMethods extends ResolvedMethodCollection = ResolvedMethodCollection, SelfStaticMethods extends ResolvedMethodCollection = ResolvedMethodCollection, Definition extends Extract<ClassDefinition, {
|
|
39
44
|
readonly kind: Kind;
|
|
@@ -113,10 +118,10 @@ export type SelfStaticMethodsOf<Class> = Class extends {
|
|
|
113
118
|
};
|
|
114
119
|
};
|
|
115
120
|
} ? Methods : ResolvedMethodCollection<Record<never, never>>;
|
|
116
|
-
type
|
|
117
|
-
[Key in keyof ByKey]?: PropertyValueOf<ByKey[Key]>;
|
|
121
|
+
type PropertyValuesInput<ByKey extends Readonly<Record<PropertyKey, ResolvedProperty<unknown>>>, ByName extends Readonly<Record<string, ResolvedProperty<unknown>>>> = Readonly<{
|
|
122
|
+
[Key in keyof ByKey]?: PropertyValueOf<ByKey[Key]> | PropertyWriteValueOf<ByKey[Key]>;
|
|
118
123
|
} & {
|
|
119
|
-
[Name in keyof ByName]?: PropertyValueOf<ByName[Name]>;
|
|
124
|
+
[Name in keyof ByName]?: PropertyValueOf<ByName[Name]> | PropertyWriteValueOf<ByName[Name]>;
|
|
120
125
|
}>;
|
|
121
126
|
type PropertyWriteInput<ByKey extends Readonly<Record<PropertyKey, ResolvedProperty<unknown>>>, ByName extends Readonly<Record<string, ResolvedProperty<unknown>>>> = Readonly<{
|
|
122
127
|
[Key in keyof ByKey]?: PropertyWriteValueOf<ByKey[Key]>;
|
|
@@ -10,6 +10,12 @@ export interface BlobRef {
|
|
|
10
10
|
export type BlobReceipt = string & {
|
|
11
11
|
readonly __brand: 'BlobReceipt';
|
|
12
12
|
};
|
|
13
|
+
/**
|
|
14
|
+
* Whether `input` has the form of an upload receipt, the ordinary write input of a blob property:
|
|
15
|
+
* text, never a Ref. Only the Kernel that issued a receipt admits it; the Ref it names must then
|
|
16
|
+
* satisfy the property's schema.
|
|
17
|
+
*/
|
|
18
|
+
export declare function isBlobReceipt(input: unknown): input is BlobReceipt;
|
|
13
19
|
/** Type-only marker; the serialized schema remains ordinary JSON. */
|
|
14
20
|
export interface BlobSchema extends JsonSchemaObject {
|
|
15
21
|
readonly [BLOB_SCHEMA]: true;
|
|
@@ -1,3 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Whether `input` has the form of an upload receipt, the ordinary write input of a blob property:
|
|
3
|
+
* text, never a Ref. Only the Kernel that issued a receipt admits it; the Ref it names must then
|
|
4
|
+
* satisfy the property's schema.
|
|
5
|
+
*/
|
|
6
|
+
export function isBlobReceipt(input) {
|
|
7
|
+
return typeof input === 'string';
|
|
8
|
+
}
|
|
1
9
|
export const BLOB_VALUE_KIND = 'blob';
|
|
2
10
|
const BLOB_DIGEST_PATTERN = 'sha256:[0-9a-f]{64}';
|
|
3
11
|
const BLOB_MEDIA_TYPE_PATTERN = "[a-z0-9!#$%&'*+.^_`|~-]+/[a-z0-9!#$%&'*+.^_`|~-]+(;[a-z0-9!#$%&'*+.^_`|~-]+=[!#$%&'*+.^_`|~0-9A-Za-z-]+)*";
|
|
@@ -80,9 +80,9 @@ export declare const CHANGES: Readonly<{
|
|
|
80
80
|
};
|
|
81
81
|
readonly EDGE_TURNED_UNDIRECTED: {
|
|
82
82
|
readonly subjects: readonly ["class.orientation"];
|
|
83
|
-
readonly statement: 'An Edge Class made undirected with no count must hold no two Edges over one pair of Nodes
|
|
83
|
+
readonly statement: 'An Edge Class made undirected with no count must hold no two Edges over one pair of Nodes. The activation stores each Edge in the canonical order of its Nodes.';
|
|
84
84
|
readonly bump: 'major';
|
|
85
|
-
readonly owes: readonly ["distinct"
|
|
85
|
+
readonly owes: readonly ["distinct"];
|
|
86
86
|
readonly disposes: readonly ["EDGE_REORIENTED"];
|
|
87
87
|
readonly also: readonly ["EDGE_TURNED_UNDIRECTED_BOUNDED"];
|
|
88
88
|
};
|
|
@@ -90,14 +90,14 @@ export declare const CHANGES: Readonly<{
|
|
|
90
90
|
readonly subjects: readonly ["class.orientation", "install.core", "endpoint.onDelete"];
|
|
91
91
|
readonly statement: 'An Edge at a Core Node the same change removes, in a Class a previous role of which restricted, restricts it, whatever the target declares: the previous orientation names the end, and the roles of the target hold none under that name.';
|
|
92
92
|
readonly bump: 'major';
|
|
93
|
-
readonly owes: readonly ["distinct"
|
|
93
|
+
readonly owes: readonly ["distinct"];
|
|
94
94
|
readonly disposes: readonly ["CORE_NODE_LEAVES", "LEAVING_NODE_RESTRICTED"];
|
|
95
95
|
};
|
|
96
96
|
readonly EDGE_TURNED_UNDIRECTED_BOUNDED: {
|
|
97
97
|
readonly subjects: readonly ["class.orientation", "endpoint.incident"];
|
|
98
98
|
readonly statement: 'An Edge Class made undirected under a count must also hold that count: its Edges now count at both ends.';
|
|
99
99
|
readonly bump: 'major';
|
|
100
|
-
readonly owes: readonly ["degree", "distinct"
|
|
100
|
+
readonly owes: readonly ["degree", "distinct"];
|
|
101
101
|
readonly disposes: readonly ["EDGE_REORIENTED"];
|
|
102
102
|
};
|
|
103
103
|
readonly EDGE_TURNED_DIRECTED: {
|
|
@@ -57,9 +57,9 @@ export const CHANGES = deepFreeze({
|
|
|
57
57
|
},
|
|
58
58
|
EDGE_TURNED_UNDIRECTED: {
|
|
59
59
|
subjects: ['class.orientation'],
|
|
60
|
-
statement: 'An Edge Class made undirected with no count must hold no two Edges over one pair of Nodes
|
|
60
|
+
statement: 'An Edge Class made undirected with no count must hold no two Edges over one pair of Nodes. The activation stores each Edge in the canonical order of its Nodes.',
|
|
61
61
|
bump: 'major',
|
|
62
|
-
owes: ['distinct'
|
|
62
|
+
owes: ['distinct'],
|
|
63
63
|
disposes: ['EDGE_REORIENTED'],
|
|
64
64
|
also: ['EDGE_TURNED_UNDIRECTED_BOUNDED'],
|
|
65
65
|
},
|
|
@@ -67,14 +67,14 @@ export const CHANGES = deepFreeze({
|
|
|
67
67
|
subjects: ['class.orientation', 'install.core', 'endpoint.onDelete'],
|
|
68
68
|
statement: 'An Edge at a Core Node the same change removes, in a Class a previous role of which restricted, restricts it, whatever the target declares: the previous orientation names the end, and the roles of the target hold none under that name.',
|
|
69
69
|
bump: 'major',
|
|
70
|
-
owes: ['distinct'
|
|
70
|
+
owes: ['distinct'],
|
|
71
71
|
disposes: ['CORE_NODE_LEAVES', 'LEAVING_NODE_RESTRICTED'],
|
|
72
72
|
},
|
|
73
73
|
EDGE_TURNED_UNDIRECTED_BOUNDED: {
|
|
74
74
|
subjects: ['class.orientation', 'endpoint.incident'],
|
|
75
75
|
statement: 'An Edge Class made undirected under a count must also hold that count: its Edges now count at both ends.',
|
|
76
76
|
bump: 'major',
|
|
77
|
-
owes: ['degree', 'distinct'
|
|
77
|
+
owes: ['degree', 'distinct'],
|
|
78
78
|
disposes: ['EDGE_REORIENTED'],
|
|
79
79
|
},
|
|
80
80
|
EDGE_TURNED_DIRECTED: {
|
|
@@ -5,7 +5,7 @@ import type { JsonSchema } from '../../language/value/model/schema.js';
|
|
|
5
5
|
import type { OrderingKind } from '../../language/value/ordering.js';
|
|
6
6
|
import type { DomainSchema } from '../model/schema.js';
|
|
7
7
|
export { VALUE_SCHEMA_DIALECT as DIALECT, VALUE_SCHEMA_VOCABULARY as VOCABULARY, } from '../../language/value/model/schema.js';
|
|
8
|
-
export { blob, isBlobValueSchema as isBlob } from '../../language/value/model/blob.js';
|
|
8
|
+
export { blob, isBlobReceipt, isBlobValueSchema as isBlob, } from '../../language/value/model/blob.js';
|
|
9
9
|
export type { BlobOptions, BlobReceipt, BlobRef, BlobSchema, } from '../../language/value/model/blob.js';
|
|
10
10
|
export { file, isFileValueSchema as isFile } from '../../language/value/model/file.js';
|
|
11
11
|
export type { FileOptions, FileSchema } from '../../language/value/model/file.js';
|
|
@@ -6,7 +6,7 @@ import { escapePointerToken } from '../../language/value/syntax/pointer.js';
|
|
|
6
6
|
import { createDomainValueSchemaRegistry } from '../resolution/value.registry.js';
|
|
7
7
|
const registries = new WeakMap();
|
|
8
8
|
export { VALUE_SCHEMA_DIALECT as DIALECT, VALUE_SCHEMA_VOCABULARY as VOCABULARY, } from '../../language/value/model/schema.js';
|
|
9
|
-
export { blob, isBlobValueSchema as isBlob } from '../../language/value/model/blob.js';
|
|
9
|
+
export { blob, isBlobReceipt, isBlobValueSchema as isBlob, } from '../../language/value/model/blob.js';
|
|
10
10
|
export { file, isFileValueSchema as isFile } from '../../language/value/model/file.js';
|
|
11
11
|
export { filePositions, locateFiles } from '../../language/value/files.js';
|
|
12
12
|
export { instant } from '../../language/value/model/instant.js';
|
package/dist/value/accept.d.ts
CHANGED
|
@@ -10,6 +10,12 @@ export declare function accept(input: unknown, options?: StructuralOptions): Val
|
|
|
10
10
|
export declare function acceptImmutable(input: unknown, options?: Options): Value;
|
|
11
11
|
/** Admit a read-only snapshot, sharing owned immutable subtrees without freezing new wrappers. */
|
|
12
12
|
export declare function acceptForRead(input: unknown, options?: StructuralOptions): Value;
|
|
13
|
+
/**
|
|
14
|
+
* The total of a trusted Value's Object members and Array elements, which `maxMembers` limits,
|
|
15
|
+
* without admitting it: an admission-owned immutable root counted its total when it was admitted,
|
|
16
|
+
* and any other container is counted member by member.
|
|
17
|
+
*/
|
|
18
|
+
export declare function memberCount(input: Value): number;
|
|
13
19
|
/**
|
|
14
20
|
* Private PropertyValues owner seam. Retain immediate recursive values, not the enclosing
|
|
15
21
|
* dictionary: its canonical coordinates are re-admitted by the Property owner on every use.
|
package/dist/value/accept.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { BoundaryError } from './error.js';
|
|
2
|
-
import { includeSnapshot, retainImmutableSnapshot, reusableSnapshot, } from './immutable.optimization.js';
|
|
2
|
+
import { immutableSnapshotMembers, includeSnapshot, retainImmutableSnapshot, reusableSnapshot, } from './immutable.optimization.js';
|
|
3
3
|
import { limitsFor } from './limits.js';
|
|
4
4
|
import { assertHostString, canonicalPrimitiveBytes } from './unicode.js';
|
|
5
5
|
/**
|
|
@@ -23,6 +23,30 @@ export function acceptImmutable(input, options) {
|
|
|
23
23
|
export function acceptForRead(input, options) {
|
|
24
24
|
return snapshot(input, options, 'read');
|
|
25
25
|
}
|
|
26
|
+
/**
|
|
27
|
+
* The total of a trusted Value's Object members and Array elements, which `maxMembers` limits,
|
|
28
|
+
* without admitting it: an admission-owned immutable root counted its total when it was admitted,
|
|
29
|
+
* and any other container is counted member by member.
|
|
30
|
+
*/
|
|
31
|
+
export function memberCount(input) {
|
|
32
|
+
let members = 0;
|
|
33
|
+
const pending = [input];
|
|
34
|
+
while (pending.length > 0) {
|
|
35
|
+
const next = pending.pop();
|
|
36
|
+
if (next === null || typeof next !== 'object')
|
|
37
|
+
continue;
|
|
38
|
+
const owned = immutableSnapshotMembers(next);
|
|
39
|
+
if (owned !== undefined) {
|
|
40
|
+
members += owned;
|
|
41
|
+
continue;
|
|
42
|
+
}
|
|
43
|
+
const items = Array.isArray(next) ? next : Object.values(next);
|
|
44
|
+
members += items.length;
|
|
45
|
+
for (const item of items)
|
|
46
|
+
pending.push(item);
|
|
47
|
+
}
|
|
48
|
+
return members;
|
|
49
|
+
}
|
|
26
50
|
/**
|
|
27
51
|
* Private PropertyValues owner seam. Retain immediate recursive values, not the enclosing
|
|
28
52
|
* dictionary: its canonical coordinates are re-admitted by the Property owner on every use.
|
|
@@ -8,6 +8,8 @@ export interface SnapshotSummary {
|
|
|
8
8
|
export declare function isImmutableSnapshot(value: object): boolean;
|
|
9
9
|
/** Exact complete representation size, only for roots retained by this admission owner. */
|
|
10
10
|
export declare function immutableSnapshotBytes(value: object): number | undefined;
|
|
11
|
+
/** Exact total of members and elements, only for roots retained by this admission owner. */
|
|
12
|
+
export declare function immutableSnapshotMembers(value: object): number | undefined;
|
|
11
13
|
/** Called only after admission has constructed and deeply frozen this container. */
|
|
12
14
|
export declare function retainImmutableSnapshot(value: object, summary: SnapshotSummary): void;
|
|
13
15
|
export declare function includeSnapshot(parent: SnapshotSummary | undefined, child: SnapshotSummary, depth: number): void;
|
|
@@ -8,6 +8,10 @@ export function isImmutableSnapshot(value) {
|
|
|
8
8
|
export function immutableSnapshotBytes(value) {
|
|
9
9
|
return snapshots.get(value)?.canonicalBytes;
|
|
10
10
|
}
|
|
11
|
+
/** Exact total of members and elements, only for roots retained by this admission owner. */
|
|
12
|
+
export function immutableSnapshotMembers(value) {
|
|
13
|
+
return snapshots.get(value)?.members;
|
|
14
|
+
}
|
|
11
15
|
/** Called only after admission has constructed and deeply frozen this container. */
|
|
12
16
|
export function retainImmutableSnapshot(value, summary) {
|
|
13
17
|
if (!snapshots.has(value))
|
package/dist/value/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/** Portable values shared by the DSL and kernel contracts. */
|
|
2
|
-
export { accept, acceptForRead, acceptImmutable } from './accept.js';
|
|
2
|
+
export { accept, acceptForRead, acceptImmutable, memberCount } from './accept.js';
|
|
3
3
|
export { equal } from './equal.js';
|
|
4
4
|
export { BoundaryError, DecodeError } from './error.js';
|
|
5
5
|
export type { BoundaryErrorCode, DecodeErrorCode } from './error.js';
|
package/dist/value/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/** Portable values shared by the DSL and kernel contracts. */
|
|
2
|
-
export { accept, acceptForRead, acceptImmutable } from './accept.js';
|
|
2
|
+
export { accept, acceptForRead, acceptImmutable, memberCount } from './accept.js';
|
|
3
3
|
export { equal } from './equal.js';
|
|
4
4
|
export { BoundaryError, DecodeError } from './error.js';
|
|
5
5
|
export { defaultLimits } from './limits.js';
|