In any formula, the symbols must be defined and the conditions under which the formula holds should be specified.
To me, $W=\vec F\cdot \vec d$ is shorthand for "the work done by a constant force $\vec F$ along a straight path represented by a displacement $\vec d$".
To allow a more general situation, $W=\vec F\cdot \vec d$
is special case of
$$W=\int_{\mbox{specified path from A to B}} \vec F \cdot d\vec r,$$
where $\vec F$ is a force that in general varies along the specific path from A to B,
and $d\vec r$ is a tiny displacement along that specific path from A to B.
Think of dividing up the path into little directed segments and consider the average force being applied during each little segment.
(In this formula, the object's velocity and acceleration do not matter.
Further, the force applied by other objects do not matter.
It's only about the specified force of interest and the path over which that force is applied.)
The "force" can be the "force applied by an external object" or it could be "the net force". One should specify.
The "force" can vary continuously and it can also vary discontinuously,
or some combination of the two. (Again, think of dividing the path into little directed segments and consider the average force over that segment.)
In the example in the answer by @EmilioPisanty ,
part of the motion may involve
the net-force due to a variable force-vector (your hand throwing [and gravity]) for part of the path,
followed by the net-force due to a different force-vector (gravity alone) for the next part of the path.
In some situations, one might be interested in the "work done by a conservative force" (like a spring force or a gravitational force or an electrostatic force).
- The usual textbook storyline (often to avoid having to reason with two minus signs) is to consider the "force you apply" to balance the "conservative force you really want to study".
- To "balance" means that you effectively move the particle with zero acceleration [and practically at rest] so that: the "net work done is zero" (the "work done by the net fore is zero") so that the change-in-kinetic-energy [from zero kinetic energy] is zero...
- so that:
the "work you did with your applied force" is equal to "the potential energy stored in the system" (that is, "minus the work done by the conservative force") when you moved from A to B (that is, changed the configuration from being-at-A to being-at-B).