Skip to content

Commit 7cdbfae

Browse files
committed
add transition to draft to active reporting options
1 parent 9516ed0 commit 7cdbfae

File tree

2 files changed

+21
-3
lines changed

2 files changed

+21
-3
lines changed

src/v3/Trace.ts

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1223,15 +1223,33 @@ export class Trace<
12231223
RelationSchemasT,
12241224
VariantsT
12251225
>,
1226-
) {
1226+
opts?: {
1227+
noDraftPresentBehavior: 'error' | 'warning' | 'noop'
1228+
},
1229+
): void {
12271230
const { attributes } = this.input
12281231

12291232
const { relatedTo, errors } = validateAndCoerceRelatedToAgainstSchema(
12301233
inputAndDefinitionModifications.relatedTo,
12311234
this.definition.relationSchema,
12321235
)
1233-
if (errors.length > 0) {
1234-
this.traceUtilities.reportWarningFn(
1236+
1237+
let reportingFunction
1238+
const { noDraftPresentBehavior } = opts ?? {}
1239+
1240+
switch (noDraftPresentBehavior) {
1241+
case 'error':
1242+
reportingFunction = this.traceUtilities.reportErrorFn
1243+
break
1244+
case 'noop':
1245+
reportingFunction = undefined
1246+
break
1247+
default:
1248+
reportingFunction = this.traceUtilities.reportWarningFn
1249+
}
1250+
1251+
if (errors.length > 0 && reportingFunction) {
1252+
reportingFunction(
12351253
new Error(
12361254
`Invalid relatedTo value: ${JSON.stringify(
12371255
inputAndDefinitionModifications.relatedTo,

src/v3/__tests__/TraceManagerWithDraft.test.ts

Whitespace-only changes.

0 commit comments

Comments
 (0)