@@ -104,11 +104,11 @@ export type Transition<RelationSchemasT> = DistributiveOmit<
104
104
type FinalizeFn < RelationSchemaT > = ( config : FinalState < RelationSchemaT > ) => void
105
105
106
106
export type States <
107
- SelectedRelationKeyT extends keyof RelationSchemasT ,
107
+ SelectedRelationNameT extends keyof RelationSchemasT ,
108
108
RelationSchemasT ,
109
109
VariantsT extends string ,
110
110
> = TraceStateMachine <
111
- SelectedRelationKeyT ,
111
+ SelectedRelationNameT ,
112
112
RelationSchemasT ,
113
113
VariantsT
114
114
> [ 'states' ]
@@ -129,11 +129,11 @@ type StatesBase<RelationSchemasT> = Record<
129
129
>
130
130
131
131
interface TraceStateMachineSideEffectHandlers <
132
- SelectedRelationKeyT extends keyof RelationSchemasT ,
132
+ SelectedRelationNameT extends keyof RelationSchemasT ,
133
133
RelationSchemasT ,
134
134
> {
135
135
readonly storeFinalizeState : FinalizeFn <
136
- RelationSchemasT [ SelectedRelationKeyT ]
136
+ RelationSchemasT [ SelectedRelationNameT ]
137
137
>
138
138
readonly addSpanToRecording : (
139
139
spanAndAnnotation : SpanAndAnnotation < RelationSchemasT > ,
@@ -148,26 +148,30 @@ type EntryType<RelationSchemasT> = PerformanceEntryLike & {
148
148
}
149
149
150
150
interface StateMachineContext <
151
- SelectedRelationKeyT extends keyof RelationSchemasT ,
151
+ SelectedRelationNameT extends keyof RelationSchemasT ,
152
152
RelationSchemasT ,
153
153
VariantsT extends string ,
154
- > extends DraftTraceContext < SelectedRelationKeyT , RelationSchemasT , VariantsT > {
154
+ > extends DraftTraceContext <
155
+ SelectedRelationNameT ,
156
+ RelationSchemasT ,
157
+ VariantsT
158
+ > {
155
159
sideEffectFns : TraceStateMachineSideEffectHandlers <
156
- SelectedRelationKeyT ,
160
+ SelectedRelationNameT ,
157
161
RelationSchemasT
158
162
>
159
163
}
160
164
161
165
type DeadlineType = 'global' | 'debounce' | 'interactive' | 'next-quiet-window'
162
166
163
167
export class TraceStateMachine <
164
- SelectedRelationKeyT extends keyof RelationSchemasT ,
168
+ SelectedRelationNameT extends keyof RelationSchemasT ,
165
169
RelationSchemasT ,
166
170
const VariantsT extends string ,
167
171
> {
168
172
constructor (
169
173
context : StateMachineContext <
170
- SelectedRelationKeyT ,
174
+ SelectedRelationNameT ,
171
175
RelationSchemasT ,
172
176
VariantsT
173
177
> ,
@@ -182,7 +186,7 @@ export class TraceStateMachine<
182
186
readonly requiredSpansIndexChecklist : Set < number >
183
187
184
188
readonly context : StateMachineContext <
185
- SelectedRelationKeyT ,
189
+ SelectedRelationNameT ,
186
190
RelationSchemasT ,
187
191
VariantsT
188
192
>
@@ -856,21 +860,21 @@ export class TraceStateMachine<
856
860
*/
857
861
emit <
858
862
EventName extends keyof StateHandlerPayloads <
859
- SelectedRelationKeyT ,
863
+ SelectedRelationNameT ,
860
864
RelationSchemasT ,
861
865
VariantsT
862
866
> ,
863
867
> (
864
868
event : EventName ,
865
869
payload : StateHandlerPayloads <
866
- SelectedRelationKeyT ,
870
+ SelectedRelationNameT ,
867
871
RelationSchemasT ,
868
872
VariantsT
869
873
> [ EventName ] ,
870
874
) : OnEnterStatePayload < RelationSchemasT > | undefined {
871
875
const currentStateHandlers = this . states [ this . currentState ] as Partial <
872
876
MergedStateHandlerMethods <
873
- SelectedRelationKeyT ,
877
+ SelectedRelationNameT ,
874
878
RelationSchemasT ,
875
879
VariantsT
876
880
>
@@ -895,42 +899,46 @@ interface PrepareAndEmitRecordingOptions<RelationSchemasT> {
895
899
}
896
900
897
901
export class Trace <
898
- const SelectedRelationKeyT extends keyof RelationSchemasT ,
902
+ const SelectedRelationNameT extends keyof RelationSchemasT ,
899
903
const RelationSchemasT ,
900
904
const VariantsT extends string ,
901
905
> {
902
906
readonly sourceDefinition : CompleteTraceDefinition <
903
- SelectedRelationKeyT ,
907
+ SelectedRelationNameT ,
904
908
RelationSchemasT ,
905
909
VariantsT
906
910
>
907
911
/** the final, mutable definition of this specific trace */
908
912
definition : CompleteTraceDefinition <
909
- SelectedRelationKeyT ,
913
+ SelectedRelationNameT ,
910
914
RelationSchemasT ,
911
915
VariantsT
912
916
>
913
917
get activeInput ( ) : ActiveTraceConfig <
914
- SelectedRelationKeyT ,
918
+ SelectedRelationNameT ,
915
919
RelationSchemasT ,
916
920
VariantsT
917
921
> {
918
922
if ( ! this . input . relatedTo ) {
919
923
throw new Error ( "Tried to access active trace's input without relatedTo" )
920
924
}
921
925
return this . input as ActiveTraceConfig <
922
- SelectedRelationKeyT ,
926
+ SelectedRelationNameT ,
923
927
RelationSchemasT ,
924
928
VariantsT
925
929
>
926
930
}
927
931
set activeInput (
928
- value : ActiveTraceConfig < SelectedRelationKeyT , RelationSchemasT , VariantsT > ,
932
+ value : ActiveTraceConfig <
933
+ SelectedRelationNameT ,
934
+ RelationSchemasT ,
935
+ VariantsT
936
+ > ,
929
937
) {
930
938
this . input = value
931
939
}
932
940
933
- input : DraftTraceInput < RelationSchemasT [ SelectedRelationKeyT ] , VariantsT >
941
+ input : DraftTraceInput < RelationSchemasT [ SelectedRelationNameT ] , VariantsT >
934
942
private readonly traceUtilities : TraceManagerUtilities < RelationSchemasT >
935
943
936
944
get isDraft ( ) {
@@ -939,7 +947,7 @@ export class Trace<
939
947
940
948
recordedItems : Set < SpanAndAnnotation < RelationSchemasT > > = new Set ( )
941
949
stateMachine : TraceStateMachine <
942
- SelectedRelationKeyT ,
950
+ SelectedRelationNameT ,
943
951
RelationSchemasT ,
944
952
VariantsT
945
953
>
@@ -949,15 +957,15 @@ export class Trace<
949
957
SpanAndAnnotation < RelationSchemasT >
950
958
> = new WeakMap ( )
951
959
952
- finalState : FinalState < RelationSchemasT [ SelectedRelationKeyT ] > | undefined
960
+ finalState : FinalState < RelationSchemasT [ SelectedRelationNameT ] > | undefined
953
961
954
962
constructor (
955
963
definition : CompleteTraceDefinition <
956
- SelectedRelationKeyT ,
964
+ SelectedRelationNameT ,
957
965
RelationSchemasT ,
958
966
VariantsT
959
967
> ,
960
- input : DraftTraceInput < RelationSchemasT [ SelectedRelationKeyT ] , VariantsT > ,
968
+ input : DraftTraceInput < RelationSchemasT [ SelectedRelationNameT ] , VariantsT > ,
961
969
traceUtilities : TraceManagerUtilities < RelationSchemasT > ,
962
970
) {
963
971
// Verify that the variant value is valid
@@ -976,8 +984,8 @@ export class Trace<
976
984
this . definition = {
977
985
name : definition . name ,
978
986
type : definition . type ,
979
- relations : definition . relations ,
980
- selectedRelationSchema : definition . selectedRelationSchema ,
987
+ relationSchemaName : definition . relationSchemaName ,
988
+ relationSchema : definition . relationSchema ,
981
989
982
990
variants : { ...definition . variants } ,
983
991
@@ -1016,7 +1024,7 @@ export class Trace<
1016
1024
}
1017
1025
1018
1026
sideEffectFns : TraceStateMachineSideEffectHandlers <
1019
- SelectedRelationKeyT ,
1027
+ SelectedRelationNameT ,
1020
1028
RelationSchemasT
1021
1029
> = {
1022
1030
storeFinalizeState : ( config ) => {
@@ -1069,13 +1077,13 @@ export class Trace<
1069
1077
}
1070
1078
1071
1079
onEnd (
1072
- traceRecording : TraceRecording < SelectedRelationKeyT , RelationSchemasT > ,
1080
+ traceRecording : TraceRecording < SelectedRelationNameT , RelationSchemasT > ,
1073
1081
) : void {
1074
1082
// @ts -expect-error TS isn't smart enough to disambiguate this situation yet; maybe in the future this will work OOTB
1075
1083
this . traceUtilities . cleanupCurrentTrace ( this )
1076
1084
; (
1077
1085
this . traceUtilities . reportFn as SingleTraceReportFn <
1078
- SelectedRelationKeyT ,
1086
+ SelectedRelationNameT ,
1079
1087
RelationSchemasT ,
1080
1088
VariantsT
1081
1089
>
@@ -1089,7 +1097,7 @@ export class Trace<
1089
1097
1090
1098
transitionDraftToActive (
1091
1099
inputAndDefinitionModifications : TraceModifications <
1092
- SelectedRelationKeyT ,
1100
+ SelectedRelationNameT ,
1093
1101
RelationSchemasT ,
1094
1102
VariantsT
1095
1103
> ,
@@ -1116,20 +1124,20 @@ export class Trace<
1116
1124
*/
1117
1125
private applyDefinitionModifications (
1118
1126
definitionModifications : TraceModificationsBase <
1119
- SelectedRelationKeyT ,
1127
+ SelectedRelationNameT ,
1120
1128
RelationSchemasT ,
1121
1129
VariantsT
1122
1130
> ,
1123
1131
) {
1124
1132
const { definition } = this
1125
1133
const additionalRequiredSpans = convertMatchersToFns <
1126
- SelectedRelationKeyT ,
1134
+ SelectedRelationNameT ,
1127
1135
RelationSchemasT ,
1128
1136
VariantsT
1129
1137
> ( definitionModifications . additionalRequiredSpans )
1130
1138
1131
1139
const additionalDebounceOnSpans = convertMatchersToFns <
1132
- SelectedRelationKeyT ,
1140
+ SelectedRelationNameT ,
1133
1141
RelationSchemasT ,
1134
1142
VariantsT
1135
1143
> ( definitionModifications . additionalDebounceOnSpans )
0 commit comments