@lorion-org/composition-graph 1.0.0-beta.1 → 1.0.0-beta.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/src/types.ts ADDED
@@ -0,0 +1,133 @@
1
+ export type DescriptorId = string;
2
+
3
+ export type DescriptorIds = DescriptorId[];
4
+
5
+ export type VersionConstraintMap = Record<DescriptorId, string>;
6
+
7
+ export type RelationId = string;
8
+
9
+ export type Descriptor = {
10
+ id: DescriptorId;
11
+ version: string;
12
+ providesFor?: DescriptorId | DescriptorId[];
13
+ defaultFor?: DescriptorId | DescriptorId[];
14
+ capabilities?: string[];
15
+ dependencies?: VersionConstraintMap;
16
+ disabled?: boolean;
17
+ location?: string;
18
+ [key: string]: unknown;
19
+ };
20
+
21
+ export type DescriptorMap = Map<DescriptorId, Descriptor>;
22
+
23
+ export type RelationDescriptor = {
24
+ direction?: 'outgoing' | 'incoming';
25
+ id: RelationId;
26
+ field?: string;
27
+ targetMode?: 'keys' | 'values';
28
+ };
29
+
30
+ export type DescriptorEdge = {
31
+ from: DescriptorId;
32
+ to: DescriptorId;
33
+ relation: RelationId;
34
+ source: 'descriptor' | 'derived';
35
+ };
36
+
37
+ export type ResolutionStep = {
38
+ from: DescriptorId;
39
+ to: DescriptorId;
40
+ relation: RelationId;
41
+ };
42
+
43
+ export type CompositionOriginType = 'selected' | 'base' | 'resolved';
44
+
45
+ export type CompositionProvenanceOrigin = {
46
+ originType: CompositionOriginType;
47
+ path: ResolutionStep[];
48
+ };
49
+
50
+ export type CompositionProvenance = {
51
+ descriptorId: DescriptorId;
52
+ origins: CompositionProvenanceOrigin[];
53
+ };
54
+
55
+ export type DescriptorGraph = {
56
+ descriptorMap: DescriptorMap;
57
+ edges: DescriptorEdge[];
58
+ outgoing: Map<DescriptorId, DescriptorEdge[]>;
59
+ incoming: Map<DescriptorId, DescriptorEdge[]>;
60
+ relationDescriptors: Map<RelationId, RelationDescriptor>;
61
+ };
62
+
63
+ export type DescriptorProfile = {
64
+ id: DescriptorId;
65
+ location?: string;
66
+ disabled: boolean;
67
+ providesFor?: DescriptorId | DescriptorId[];
68
+ capabilities: string[];
69
+ outgoing: Record<RelationId, string[]>;
70
+ incoming: Record<RelationId, string[]>;
71
+ };
72
+
73
+ export type CompositionPolicy = {
74
+ resolutionRelationIds: RelationId[];
75
+ provenanceRelationIds: RelationId[];
76
+ inspectionRelationIds: RelationId[];
77
+ };
78
+
79
+ export type DescriptorCatalog = {
80
+ getDescriptorMap: () => DescriptorMap;
81
+ getAllDescriptors: () => Descriptor[];
82
+ getDescriptor: (id: DescriptorId) => Descriptor | undefined;
83
+ getGraph: () => DescriptorGraph;
84
+ getRelationDescriptors: () => RelationDescriptor[];
85
+ getProfiles: (input?: { ids?: DescriptorId[]; includeDisabled?: boolean }) => DescriptorProfile[];
86
+ getIncomingRelationMap: (relationId: RelationId) => Map<DescriptorId, DescriptorId[]>;
87
+ getTransitiveTargets: (input: {
88
+ start: DescriptorId[];
89
+ relationIds: RelationId[];
90
+ }) => DescriptorIds;
91
+ getDependents: (input: {
92
+ target: DescriptorId;
93
+ relationIds: RelationId[];
94
+ transitive?: boolean;
95
+ }) => DescriptorIds;
96
+ explain: (input: {
97
+ from: DescriptorId;
98
+ to: DescriptorId;
99
+ relationIds: RelationId[];
100
+ }) => ResolutionStep[];
101
+ explainPathsBatch: (input: {
102
+ pairs: Array<{ from: DescriptorId; to: DescriptorId }>;
103
+ relationIds: RelationId[];
104
+ }) => Array<{ from: DescriptorId; to: DescriptorId; path: ResolutionStep[] }>;
105
+ resolveSelection: (input: {
106
+ selected?: DescriptorId[];
107
+ baseDescriptors?: DescriptorId[];
108
+ policy?: Partial<CompositionPolicy>;
109
+ }) => CompositionSelection;
110
+ };
111
+
112
+ export type CompositionSelection = {
113
+ getCatalog: () => DescriptorCatalog;
114
+ getGraph: () => DescriptorGraph;
115
+ getSelected: () => DescriptorIds;
116
+ getBaseDescriptors: () => DescriptorIds;
117
+ getResolved: () => DescriptorIds;
118
+ getResolvedDescriptors: () => Descriptor[];
119
+ getProvenance: () => CompositionProvenance[];
120
+ getDependentsFor: (
121
+ target: DescriptorId,
122
+ input?: { transitive?: boolean; relationIds?: RelationId[] },
123
+ ) => DescriptorIds;
124
+ explain: (input: {
125
+ from: DescriptorId;
126
+ to: DescriptorId;
127
+ relationIds?: RelationId[];
128
+ }) => ResolutionStep[];
129
+ explainPathsBatch: (input: {
130
+ pairs: Array<{ from: DescriptorId; to: DescriptorId }>;
131
+ relationIds?: RelationId[];
132
+ }) => Array<{ from: DescriptorId; to: DescriptorId; path: ResolutionStep[] }>;
133
+ };