@astrale-os/kernel-dsl 1.0.0-beta.29 → 1.0.0-beta.30
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.
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import type * as language from '../../../language/index.js';
|
|
2
|
-
import type { DomainSchema
|
|
2
|
+
import type { DomainSchema } from '../../../schema/model/schema.js';
|
|
3
3
|
import type { NodeClass, DirectedEdgeClass, UndirectedEdgeClass, Class, ProjectionOfClass } from '../../class/handle.js';
|
|
4
4
|
import type { ClassReferenceProjection } from '../../class/projection.js';
|
|
5
5
|
import type { DomainSchemaInput } from '../input.js';
|
|
6
6
|
import type { OwnInstanceMethodProjectionsOf, OwnStaticMethodProjectionsOf } from './callable.js';
|
|
7
|
-
import type { AbstractOf, ConstraintsOf, ResolveLazy,
|
|
7
|
+
import type { AbstractOf, ConstraintsOf, ResolveLazy, NameOfReference, ClassesInputOf, LocalNameOf, RecordField, DependencyClassesOf } from './identity.js';
|
|
8
8
|
import type { ClassProjection } from './model.js';
|
|
9
9
|
import type { EffectivePropertyProjectionsOf, OwnPropertyProjectionsOf } from './property.js';
|
|
10
10
|
import type { ClassProjectionOfResolved, ExactClass } from './resolved-class.js';
|
|
@@ -43,63 +43,22 @@ type ClassMarkOf<Value> = Value extends NodeClass<infer Config> ? {
|
|
|
43
43
|
} ? Name : never : never : never;
|
|
44
44
|
} : never;
|
|
45
45
|
type Same<Left, Right> = [Left] extends [Right] ? ([Right] extends [Left] ? true : false) : false;
|
|
46
|
-
/** Every
|
|
47
|
-
type
|
|
48
|
-
[Name in keyof
|
|
49
|
-
}[keyof
|
|
46
|
+
/** Every authored Class name whose mark is the accepted mark. */
|
|
47
|
+
type NameOfMark<Classes, Mark> = {
|
|
48
|
+
[Name in keyof Classes]: Same<ClassMarkOf<Classes[Name]>, Mark> extends true ? Name : never;
|
|
49
|
+
}[keyof Classes];
|
|
50
50
|
/**
|
|
51
51
|
* Every Class an authored handle bearing the mark may be: the builder resolves the handle of a
|
|
52
52
|
* Class of the Schema or of a direct dependency, so either may bear it. The ref stays broad when no
|
|
53
53
|
* Class bears it or a dependency's Classes are not named in the types.
|
|
54
54
|
*/
|
|
55
|
-
type MarkedClassRefOf<Origin extends string, Mark, Root extends DomainSchemaInput> = LocalClassRefOf<Origin,
|
|
55
|
+
type MarkedClassRefOf<Origin extends string, Mark, Root extends DomainSchemaInput> = LocalClassRefOf<Origin, NameOfMark<ClassesInputOf<Root>, Mark>> | DependencyClassRefOfMark<Root, Mark> extends infer Refs ? [Refs] extends [never] ? language.ClassRef : Refs : never;
|
|
56
56
|
type LocalClassRefOf<Origin extends string, Name> = Name extends string ? language.ClassRef<Name> & {
|
|
57
57
|
readonly origin: Origin;
|
|
58
58
|
} : never;
|
|
59
|
-
/**
|
|
60
|
-
type MemberNamesOf<Collection> = Collection extends {
|
|
61
|
-
readonly byKey: infer ByKey;
|
|
62
|
-
} ? ByKey[keyof ByKey] extends infer Member ? Member extends {
|
|
63
|
-
readonly name: infer Name;
|
|
64
|
-
} ? Name : never : never : never;
|
|
65
|
-
/**
|
|
66
|
-
* A dependency Class may bear a mark when it agrees with it in abstractness and the names of its
|
|
67
|
-
* effective Properties, and its own Methods are among the mark's. Its resolved type keeps neither
|
|
68
|
-
* its depth nor the abstract Methods it inherits, so neither is compared.
|
|
69
|
-
*/
|
|
70
|
-
type ResolvedBearsMark<Value, Mark> = Value extends {
|
|
71
|
-
readonly kind: 'node';
|
|
72
|
-
readonly definition: {
|
|
73
|
-
readonly abstract: infer Abstract;
|
|
74
|
-
};
|
|
75
|
-
readonly properties: infer Properties;
|
|
76
|
-
readonly methods: infer Methods;
|
|
77
|
-
readonly static: {
|
|
78
|
-
readonly methods: infer StaticMethods;
|
|
79
|
-
};
|
|
80
|
-
} ? Mark extends {
|
|
81
|
-
readonly abstract: infer MarkAbstract;
|
|
82
|
-
readonly properties: infer MarkProperties;
|
|
83
|
-
readonly methods: infer MarkMethods;
|
|
84
|
-
} ? Same<{
|
|
85
|
-
readonly abstract: Abstract;
|
|
86
|
-
readonly properties: MemberNamesOf<Properties>;
|
|
87
|
-
}, {
|
|
88
|
-
readonly abstract: MarkAbstract;
|
|
89
|
-
readonly properties: MarkProperties;
|
|
90
|
-
}> extends true ? [MemberNamesOf<Methods> | MemberNamesOf<StaticMethods>] extends [MarkMethods] ? true : false : false : false : false;
|
|
91
|
-
/** Every Node Class of a direct dependency that may bear the mark. */
|
|
59
|
+
/** Every Node Class of a direct dependency whose authored handle bears the mark. */
|
|
92
60
|
type DependencyClassRefOfMark<Root extends DomainSchemaInput, Mark> = {
|
|
93
|
-
[Alias in keyof RecordField<Root, 'dependencies'>]: RecordField<Root, 'dependencies'>[Alias] extends infer Schema extends DomainSchema ?
|
|
94
|
-
[Name in keyof Classes]: ResolvedBearsMark<Classes[Name], Mark> extends true ? Classes[Name] extends {
|
|
95
|
-
readonly ref: {
|
|
96
|
-
readonly origin: infer RefOrigin extends string;
|
|
97
|
-
readonly name: infer RefName extends string;
|
|
98
|
-
};
|
|
99
|
-
} ? language.ClassRef<RefName> & {
|
|
100
|
-
readonly origin: RefOrigin;
|
|
101
|
-
} : never : never;
|
|
102
|
-
}[keyof Classes] : never : never;
|
|
61
|
+
[Alias in keyof RecordField<Root, 'dependencies'>]: RecordField<Root, 'dependencies'>[Alias] extends infer Schema extends DomainSchema ? DependencyClassesOf<Schema> extends infer Classes ? [Classes] extends [never] ? language.ClassRef : LocalClassRefOf<Schema['origin'], NameOfMark<Classes, Mark>> : never : never;
|
|
103
62
|
}[keyof RecordField<Root, 'dependencies'>];
|
|
104
63
|
/** Every Class an endpoint accepts, in any order: the runtime list is canonically sorted. */
|
|
105
64
|
type AcceptedRefsOf<Origin extends string, Accepts, Root extends DomainSchemaInput> = Accepts extends readonly (infer Reference)[] ? readonly [AcceptedRefOf<Origin, Reference, Root>, ...AcceptedRefOf<Origin, Reference, Root>[]] : readonly [language.ClassRef, ...language.ClassRef[]];
|
|
@@ -175,7 +134,7 @@ type ProjectedClassDefinition<Origin extends string, Name extends string, Value,
|
|
|
175
134
|
type ParentInputsOfConfig<Config> = Config extends {
|
|
176
135
|
readonly extends?: infer Parents extends readonly unknown[];
|
|
177
136
|
} ? Parents : readonly [];
|
|
178
|
-
type ParentClassProjectionOf<Origin extends string, Parent, Root extends DomainSchemaInput, Seen> = ResolveLazy<Parent> extends infer Resolved ? Resolved extends ClassReferenceProjection<infer _Kind, infer _Identity, infer _Properties, infer _InstanceMethods, infer _StaticMethods> ?
|
|
137
|
+
type ParentClassProjectionOf<Origin extends string, Parent, Root extends DomainSchemaInput, Seen> = ResolveLazy<Parent> extends infer Resolved ? Resolved extends ClassReferenceProjection<infer _Kind, infer _Identity, infer _Properties, infer _InstanceMethods, infer _StaticMethods> ? NameOfReference<ClassesInputOf<Root>, Resolved> extends infer Name extends string ? Name extends keyof ClassesInputOf<Root> ? ShallowClassProjectionOfAuthoring<Origin, Name, Extract<ClassesInputOf<Root>[Name], Class>, Root> : never : never : Resolved extends ClassProjection ? Resolved : Resolved extends language.AnyResolvedClass ? ClassProjectionOfResolved<ExactClass<Resolved>> : LocalNameOf<Root, Resolved> extends infer Name extends string ? Resolved extends Seen ? never : ClassProjectionOfAuthoring<Origin, Name, Resolved, Root, Seen | Resolved> : never : never;
|
|
179
138
|
type ParentClassProjectionTuple<Origin extends string, Parents extends readonly unknown[], Root extends DomainSchemaInput, Seen> = Parents extends readonly [] ? readonly [] : Parents extends readonly [infer Parent, ...infer Rest] ? readonly [
|
|
180
139
|
ParentClassProjectionOf<Origin, Parent, Root, Seen>,
|
|
181
140
|
...ParentClassProjectionTuple<Origin, Rest, Root, Seen>
|
|
@@ -43,8 +43,19 @@ interface DomainOfProjection<Projection extends DomainProjection> extends domain
|
|
|
43
43
|
readonly [Alias in keyof Projection['dependencies']]: Projection['dependencies'][Alias] extends infer Dependency extends DomainSchema ? DomainOfSchema<Dependency> : never;
|
|
44
44
|
}>;
|
|
45
45
|
}
|
|
46
|
-
|
|
47
|
-
|
|
46
|
+
declare const AUTHORED_CLASSES: unique symbol;
|
|
47
|
+
/**
|
|
48
|
+
* Resolve compact authored witnesses into the exact public Domain type. The type names the
|
|
49
|
+
* authored handles of its Classes, so a Schema depending on this one reads them, through any type
|
|
50
|
+
* that extends it.
|
|
51
|
+
*/
|
|
52
|
+
export interface ResolvedDomainOfInput<Origin extends string, Input extends DomainSchemaInput> extends DomainOfProjection<ProjectionOfInput<Origin, Input>> {
|
|
53
|
+
readonly [AUTHORED_CLASSES]: ClassesInputOf<Input>;
|
|
54
|
+
}
|
|
55
|
+
/** The authored handles of a resolved Domain's Classes: `never` when its type names none. */
|
|
56
|
+
export type AuthoredClassesOf<Value> = Value extends {
|
|
57
|
+
readonly [AUTHORED_CLASSES]: infer Classes extends NonNullable<DomainSchemaInput['classes']>;
|
|
58
|
+
} ? Classes : never;
|
|
48
59
|
type DependenciesInputOf<Input extends DomainSchemaInput> = RecordField<Input, 'dependencies'>;
|
|
49
60
|
type DependencySchemasOf<Input extends DomainSchemaInput> = {
|
|
50
61
|
readonly [Alias in keyof DependenciesInputOf<Input>]: DependenciesInputOf<Input>[Alias];
|
|
@@ -1,6 +1,8 @@
|
|
|
1
|
+
import type { DomainSchema, DomainOfSchema } from '../../../schema/model/schema.js';
|
|
1
2
|
import type { NodeClass, DirectedEdgeClass, UndirectedEdgeClass, Class } from '../../class/handle.js';
|
|
2
3
|
import type { ClassReferenceProjection, ClassReferenceProjectionOf, ClassIdentityProjectionOf, ClassOwnerProjectionOf, ClassOwnerProjection, ClassIdentityProjection } from '../../class/projection.js';
|
|
3
4
|
import type { DomainSchemaInput } from '../input.js';
|
|
5
|
+
import type { AuthoredClassesOf } from './domain.js';
|
|
4
6
|
/** Extract an authored abstract modifier with its default. */
|
|
5
7
|
export type AbstractOf<Config> = Config extends {
|
|
6
8
|
readonly abstract: infer Abstract extends boolean;
|
|
@@ -9,8 +11,11 @@ export type AbstractOf<Config> = Config extends {
|
|
|
9
11
|
export type ConstraintsOf<Options> = Options extends {
|
|
10
12
|
readonly constraints?: infer Constraints;
|
|
11
13
|
} ? NonNullable<Constraints> : Record<never, never>;
|
|
12
|
-
/**
|
|
13
|
-
|
|
14
|
+
/**
|
|
15
|
+
* Extract one named declaration dictionary. A field that is absent, `undefined` or `never` declares
|
|
16
|
+
* nothing.
|
|
17
|
+
*/
|
|
18
|
+
export type RecordField<Value, Key extends PropertyKey> = Key extends keyof Value ? [NonNullable<Value[Key]>] extends [never] ? Record<never, never> : NonNullable<Value[Key]> extends Readonly<Record<string, unknown>> ? NonNullable<Value[Key]> : Record<never, never> : Record<never, never>;
|
|
14
19
|
/** Select the local Class dictionary of a schema input. */
|
|
15
20
|
export type ClassesInputOf<Input extends DomainSchemaInput> = RecordField<Input, 'classes'>;
|
|
16
21
|
/** Unwrap lazy references within the existing 32-step inference budget. */
|
|
@@ -22,10 +27,10 @@ type Same<Left, Right> = [Left] extends [Right] ? ([Right] extends [Left] ? true
|
|
|
22
27
|
export type LocalNameOf<Root extends DomainSchemaInput, Value> = {
|
|
23
28
|
[Name in keyof ClassesInputOf<Root>]: Same<ClassesInputOf<Root>[Name], Value> extends true ? Name : never;
|
|
24
29
|
}[keyof ClassesInputOf<Root>];
|
|
25
|
-
/** Find
|
|
26
|
-
export type
|
|
27
|
-
[Name in keyof
|
|
28
|
-
}[keyof
|
|
30
|
+
/** Find an authored Class by the reference projection its handle keeps. */
|
|
31
|
+
export type NameOfReference<Classes, Value> = {
|
|
32
|
+
[Name in keyof Classes]: Value extends ClassReferenceProjection<'node' | 'edge', unknown, unknown, unknown, unknown> ? Same<ClassReferenceProjectionOf<Extract<Classes[Name], Class>>, Value> extends true ? Name : never : never;
|
|
33
|
+
}[keyof Classes];
|
|
29
34
|
type LocalNameOfIdentity<Root extends DomainSchemaInput, Value> = {
|
|
30
35
|
[Name in keyof ClassesInputOf<Root>]: Same<ClassIdentityProjectionOf<Extract<ClassesInputOf<Root>[Name], Class>>, Value> extends true ? Name : never;
|
|
31
36
|
}[keyof ClassesInputOf<Root>];
|
|
@@ -35,21 +40,65 @@ type LocalNameOfOwner<Root extends DomainSchemaInput, Value> = {
|
|
|
35
40
|
type UnionIsMultiple<Value, Whole = Value> = Value extends unknown ? [Whole] extends [Value] ? false : true : never;
|
|
36
41
|
/** Distinguish ambiguous unions from one exact member. */
|
|
37
42
|
export type IsMultiple<Value> = true extends UnionIsMultiple<Value> ? true : false;
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
type
|
|
43
|
-
/**
|
|
44
|
-
|
|
43
|
+
/**
|
|
44
|
+
* The authored handles of a dependency's Classes, as its type keeps them: `never` when its type
|
|
45
|
+
* names neither those handles nor their names.
|
|
46
|
+
*/
|
|
47
|
+
export type DependencyClassesOf<Dependency> = Dependency extends DomainSchema ? AuthoredClassesOf<DomainOfSchema<Dependency>> extends infer Classes ? string extends keyof Classes ? never : Classes : never : never;
|
|
48
|
+
/**
|
|
49
|
+
* Whether a Class of a direct dependency may be the Class a reference projects: one whose authored
|
|
50
|
+
* handle keeps the same reference, as for a Class of the Schema. A value has the reference of a
|
|
51
|
+
* dependency's Class only through a type that names that Class, so a dependency whose Classes the
|
|
52
|
+
* types do not name holds none.
|
|
53
|
+
*/
|
|
54
|
+
type DependencyMayBe<Root extends DomainSchemaInput, Value> = Value extends ClassReferenceProjection<'node' | 'edge', unknown, unknown, unknown, unknown> ? [
|
|
55
|
+
{
|
|
56
|
+
[Alias in keyof RecordField<Root, 'dependencies'>]: NameOfReference<DependencyClassesOf<RecordField<Root, 'dependencies'>[Alias]>, Value>;
|
|
57
|
+
}[keyof RecordField<Root, 'dependencies'>]
|
|
58
|
+
] extends [never] ? false : true : false;
|
|
59
|
+
/**
|
|
60
|
+
* The Classes of the Schema a parent may be: those its projection matches, but the Class being
|
|
61
|
+
* read, which is no ancestor of itself.
|
|
62
|
+
*/
|
|
63
|
+
type LocalClassesOfParent<Root extends DomainSchemaInput, Parent, CurrentName> = Exclude<NameOfReference<ClassesInputOf<Root>, ResolveLazy<Parent>>, CurrentName>;
|
|
64
|
+
/**
|
|
65
|
+
* Whether a parent is a candidate owner whichever Class of the Schema it is: a union of Classes may
|
|
66
|
+
* not be. A dependency's Class bearing its projection declares the Property too, so two parents
|
|
67
|
+
* among the candidates bring two Properties whichever Classes they are.
|
|
68
|
+
*/
|
|
69
|
+
type IsAmong<Names, Owners> = [Names] extends [never] ? false : [Names] extends [Owners] ? true : false;
|
|
70
|
+
type ParentsAmong<Root extends DomainSchemaInput, Parents, CurrentName, Owners> = Parents extends readonly [infer Parent, ...infer Rest] ? IsAmong<LocalClassesOfParent<Root, Parent, CurrentName>, Owners> extends true ? readonly [Parent, ...ParentsAmong<Root, Rest, CurrentName, Owners>] : ParentsAmong<Root, Rest, CurrentName, Owners> : readonly [];
|
|
71
|
+
type ParentsOf<Value> = ClassInputOf<Value> extends {
|
|
45
72
|
readonly extends: infer Parents extends readonly unknown[];
|
|
46
|
-
} ?
|
|
73
|
+
} ? Parents : readonly [];
|
|
74
|
+
/**
|
|
75
|
+
* The Class a parent is, when it can be only one Class of the Schema and no Class of a direct
|
|
76
|
+
* dependency, whose authored handle may bear its projection.
|
|
77
|
+
*/
|
|
78
|
+
type ExactNameOfParent<Root extends DomainSchemaInput, Parent, CurrentName> = Parent extends unknown ? LocalClassesOfParent<Root, Parent, CurrentName> extends infer Name ? IsMultiple<Name> extends true ? never : DependencyMayBe<Root, ResolveLazy<Parent>> extends true ? never : Name : never : never;
|
|
79
|
+
type ExactNamesOfParents<Root extends DomainSchemaInput, Names, CurrentName> = Names extends keyof ClassesInputOf<Root> ? ExactNameOfParent<Root, ParentsOf<ClassesInputOf<Root>[Names]>[number], CurrentName> : never;
|
|
80
|
+
type SomeHasTwoParentsAmong<Root extends DomainSchemaInput, Names, CurrentName, Owners> = Names extends keyof ClassesInputOf<Root> ? ParentsAmong<Root, ParentsOf<ClassesInputOf<Root>[Names]>, CurrentName, Owners>['length'] extends 0 | 1 ? never : true : never;
|
|
81
|
+
/**
|
|
82
|
+
* Level by level: a level is a union, so a Class that two paths reach is read once on it, and a
|
|
83
|
+
* level holds no Class an earlier one read, so the walk ends within the Classes of the Schema. Each
|
|
84
|
+
* reference to the walk is read through `true extends`, so the checker relates two instantiations
|
|
85
|
+
* of it without unrolling the walk.
|
|
86
|
+
*/
|
|
87
|
+
type AncestorsHoldOwnersApart<Root extends DomainSchemaInput, Names, CurrentName, Owners, Seen = never> = [Names] extends [never] ? false : [SomeHasTwoParentsAmong<Root, Names, CurrentName, Owners>] extends [never] ? true extends AncestorsHoldOwnersApart<Root, Exclude<ExactNamesOfParents<Root, Names, CurrentName>, Seen | Names>, CurrentName, Owners, Seen | Names> ? true : false : true;
|
|
88
|
+
/**
|
|
89
|
+
* Whether two parents of the Class are among the candidate owners, or of a Class it extends that
|
|
90
|
+
* only one Class of the Schema can be: an ancestor alike to another says nothing about either.
|
|
91
|
+
*/
|
|
92
|
+
type HoldsOwnersApart<Root extends DomainSchemaInput, Value, CurrentName, Owners> = ParentsAmong<Root, ParentsOf<Value>, CurrentName, Owners>['length'] extends 0 | 1 ? true extends AncestorsHoldOwnersApart<Root, ExactNameOfParent<Root, ParentsOf<Value>[number], CurrentName>, CurrentName, Owners> ? true : false : true;
|
|
47
93
|
/**
|
|
48
94
|
* The candidate owners of each Property an inherited member is on the Class. Classes alike in shape
|
|
49
|
-
* are one owner to the types
|
|
50
|
-
*
|
|
95
|
+
* are one owner to the types. A Class has one Property, under the key of each candidate, unless the
|
|
96
|
+
* types are sure it has one per owner: in doubt, a reader finds the Property by its name.
|
|
97
|
+
*/
|
|
98
|
+
export type OwnersOfEachProperty<Root extends DomainSchemaInput, Value, CurrentName, Owners> = IsMultiple<Owners> extends true ? true extends HoldsOwnersApart<Root, Value, CurrentName, Owners> ? Owners extends unknown ? readonly [Owners] : never : readonly [Owners] : readonly [Owners];
|
|
99
|
+
/**
|
|
100
|
+
* Recover the local declaring Class name for an effective member. An inherited member's owner is an
|
|
101
|
+
* ancestor, so never the Class being read, even when the two are alike.
|
|
51
102
|
*/
|
|
52
|
-
export type
|
|
53
|
-
/** Recover the local declaring Class name for an effective member. */
|
|
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;
|
|
103
|
+
export type OwnerNameOf<Root extends DomainSchemaInput, CurrentName extends string, Owner> = Owner extends 'self' ? CurrentName : Owner extends ClassOwnerProjection ? Exclude<Extract<LocalNameOfOwner<Root, Owner>, string>, CurrentName> : Owner extends ClassIdentityProjection ? Exclude<Extract<LocalNameOfIdentity<Root, Owner>, string>, CurrentName> : never;
|
|
55
104
|
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, OwnersOfEachProperty } from './identity.js';
|
|
4
|
+
import type { RecordField, ClassInputOf, IsMultiple, 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,41 @@ 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, 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;
|
|
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, CurrentName, 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
|
+
/** The entries of this name under one key: Properties the types are sure of. */
|
|
31
|
+
type SureEntriesNamed<All, Name> = All extends {
|
|
32
|
+
readonly name: Name;
|
|
33
|
+
readonly key: infer Key;
|
|
34
|
+
} ? [Key] extends [never] ? never : IsMultiple<Key> extends true ? never : All : never;
|
|
35
|
+
/** The entries of this name in doubt among keys, `Key` not among them. */
|
|
36
|
+
type DoubtsWithout<All, Name, Key> = All extends {
|
|
37
|
+
readonly name: Name;
|
|
38
|
+
readonly key: infer Keys;
|
|
39
|
+
} ? IsMultiple<Keys> extends true ? [Key] extends [Keys] ? never : All : never : never;
|
|
40
|
+
/** The names of the entries under several candidate keys, or under one. */
|
|
41
|
+
type NamesUnder<All, Several extends boolean> = All extends {
|
|
42
|
+
readonly name: infer Name;
|
|
43
|
+
readonly key: infer Key;
|
|
44
|
+
} ? IsMultiple<Key> extends Several ? Name : never : never;
|
|
45
|
+
/**
|
|
46
|
+
* Only a dependency brings an entry under one key among the keys of an entry in doubt: in this
|
|
47
|
+
* Schema, the candidates of an inherited Property are the Classes alike to its owner but the Class
|
|
48
|
+
* being read, so those of two Properties are the same Classes or share none, and the Class's own
|
|
49
|
+
* Properties are under its own key. A Schema without dependencies reads its entries as they are.
|
|
50
|
+
*/
|
|
51
|
+
type OneEntryPerDoubtIn<Root, All> = [keyof RecordField<Root, 'dependencies'>] extends [never] ? All : OneEntryPerDoubt<All>;
|
|
52
|
+
/**
|
|
53
|
+
* A dependency's Class brings its Property under the key of each candidate, and another path can
|
|
54
|
+
* bring the same Property under one of them. An entry of a name goes when it spans exactly the keys
|
|
55
|
+
* of the name's entries under one key and every entry in doubt bears all of them: those entries
|
|
56
|
+
* stand for it. So the only entry under one key goes when every entry in doubt bears its key, as in
|
|
57
|
+
* doubt the types read one Property, and an entry in doubt among exactly the keys of several
|
|
58
|
+
* entries under one key goes, as it is one of those sure Properties. Every other entry stands.
|
|
59
|
+
*/
|
|
60
|
+
type OneEntryPerDoubt<All, Doubts = Extract<NamesUnder<All, true>, NamesUnder<All, false>>, Each = All> = [Doubts] extends [never] ? All : Each extends {
|
|
61
|
+
readonly name: infer Name;
|
|
62
|
+
readonly key: infer Key;
|
|
63
|
+
} ? Name extends Doubts ? [SureEntriesNamed<All, Name>] extends [Each] ? [Each] extends [SureEntriesNamed<All, Name>] ? [DoubtsWithout<All, Name, Key>] extends [never] ? never : Each : Each : Each : Each : never;
|
|
30
64
|
/** 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, Value, Root, Entry> : never : never
|
|
65
|
+
export type EffectivePropertyProjectionsOf<Origin extends string, Name extends string, Value, Root extends DomainSchemaInput> = OneEntryPerDoubtIn<Root, EffectivePropertyEntriesOfClass<Value> extends infer Entry ? Entry extends unknown ? EffectivePropertyProjectionOfEntry<Origin, Name, Value, Root, Entry> : never : never>;
|
|
32
66
|
export {};
|