[guided]We now build the generating function. The previous step gave a function $A$ satisfying
\begin{align*}
d_{t,z,\eta}A=\xi(t;z,\eta)\cdot d_{t,z,\eta}y(t;z,\eta)-\lambda(t,y(t;z,\eta),\xi(t;z,\eta))\,dt-\eta\cdot dz.
\end{align*}
The symbol $d_{t,z,\eta}y(t;z,\eta)$ means the full differential of the map $(t,z,\eta)\mapsto y(t;z,\eta)$, paired with the covector $\xi(t;z,\eta)$.
The type-II generating function should use $(y,\eta)$ as independent variables. Since the inverse map gives $z=Z(t,y,\eta)$, define
\begin{align*}
S:\Omega_0\to\mathbb{R},\qquad S(t,y,\eta)=A(t,Z(t,y,\eta),\eta)+Z(t,y,\eta)\cdot\eta.
\end{align*}
The added term $Z\cdot\eta$ is chosen so that the unwanted $-\eta\cdot dz$ term in $dA$ cancels when we differentiate.
Indeed, differentiate $S$ using the chain rule. The differential of $A(t,Z(t,y,\eta),\eta)$ is obtained by substituting $z=Z(t,y,\eta)$ into the displayed identity for $dA$. Since $y(t;Z(t,y,\eta),\eta)=y$, differentiating this identity gives $d_{t,y,\eta}(y(t;Z(t,y,\eta),\eta))=dy$. Hence the full differential term becomes $\Xi(t,y,\eta)\cdot dy$. The term involving $-\eta\cdot dZ$ also appears. The differential of $Z(t,y,\eta)\cdot\eta$ is
\begin{align*}
\eta\cdot dZ(t,y,\eta)+Z(t,y,\eta)\cdot d\eta.
\end{align*}
The two terms $\eta\cdot dZ$ and $-\eta\cdot dZ$ cancel. Since the inverse relation says $y(t;Z(t,y,\eta),\eta)=y$, the remaining differential is
\begin{align*}
d_{t,y,\eta}S=\Xi(t,y,\eta)\cdot dy+Z(t,y,\eta)\cdot d\eta-\lambda(t,y,\Xi(t,y,\eta))\,dt.
\end{align*}
Reading off coefficients of the independent differentials $dy$, $d\eta$, and $dt$ gives
\begin{align*}
\partial_y S(t,y,\eta)=\Xi(t,y,\eta).
\end{align*}
\begin{align*}
\partial_\eta S(t,y,\eta)=Z(t,y,\eta).
\end{align*}
\begin{align*}
\partial_t S(t,y,\eta)=-\lambda(t,y,\Xi(t,y,\eta)).
\end{align*}
Because $\partial_y S=\Xi$, the last identity becomes
\begin{align*}
\partial_t S(t,y,\eta)+\lambda(t,y,\partial_yS(t,y,\eta))=0.
\end{align*}
This is the Hamilton-Jacobi equation. At time $t=0$, the spatial flow is the identity, so $Z(0,y,\eta)=y$. The normalization $A(0,z,\eta)=0$ therefore gives
\begin{align*}
S(0,y,\eta)=y\cdot\eta.
\end{align*}[/guided]