({
interpolationContext,
}: {
interpolationContext: JobInterpolationContext;
})
| 87 | } |
| 88 | |
| 89 | public getValue({ |
| 90 | interpolationContext, |
| 91 | }: { |
| 92 | interpolationContext: JobInterpolationContext; |
| 93 | }): R extends true ? BuildStepInputValueType<T> : BuildStepInputValueType<T> | undefined { |
| 94 | const rawValue = this._value ?? this.defaultValue; |
| 95 | if (this.required && rawValue === undefined) { |
| 96 | throw new BuildStepRuntimeError( |
| 97 | `Input parameter "${this.id}" for step "${this.stepDisplayName}" is required but it was not set.` |
| 98 | ); |
| 99 | } |
| 100 | |
| 101 | const interpolatedValue = interpolateJobContext({ |
| 102 | target: rawValue, |
| 103 | context: interpolationContext, |
| 104 | }); |
| 105 | |
| 106 | const valueDoesNotRequireInterpolation = |
| 107 | interpolatedValue === undefined || |
| 108 | interpolatedValue === null || |
| 109 | typeof interpolatedValue === 'boolean' || |
| 110 | typeof interpolatedValue === 'number'; |
| 111 | let returnValue; |
| 112 | if (valueDoesNotRequireInterpolation) { |
| 113 | if ( |
| 114 | typeof interpolatedValue !== this.allowedValueTypeName && |
| 115 | interpolatedValue !== undefined |
| 116 | ) { |
| 117 | throw new BuildStepRuntimeError( |
| 118 | `Input parameter "${this.id}" for step "${this.stepDisplayName}" must be of type "${this.allowedValueTypeName}".` |
| 119 | ); |
| 120 | } |
| 121 | returnValue = interpolatedValue as BuildStepInputValueType<T>; |
| 122 | } else { |
| 123 | // `valueDoesNotRequireInterpolation` checks that `rawValue` is not undefined |
| 124 | // so this will never be true. |
| 125 | assert(interpolatedValue !== undefined); |
| 126 | const valueInterpolatedWithGlobalContext = this.ctx.interpolate(interpolatedValue); |
| 127 | const valueInterpolatedWithOutputsAndGlobalContext = interpolateWithOutputs( |
| 128 | valueInterpolatedWithGlobalContext, |
| 129 | path => this.ctx.getStepOutputValue(path) ?? '' |
| 130 | ); |
| 131 | returnValue = this.parseInputValueToAllowedType(valueInterpolatedWithOutputsAndGlobalContext); |
| 132 | } |
| 133 | return returnValue; |
| 134 | } |
| 135 | |
| 136 | public get rawValue(): unknown { |
| 137 | return this._value ?? this.defaultValue; |
no test coverage detected