@dgac/nmb2b-client
Version:
EUROCONTROL Network Manager B2B SOAP client
43 lines • 1.38 kB
text/typescript
//#region src/utils/hooks/hooks.d.ts
/**
* A hook that will be executed when a query starts.
*
* A hook can return an object with optional properties :
* - `onRequestSuccess`: a hook executed when the query is successful
* - `onRequestError`: a hook executed when the query fails
*
* All hooks can be sync or async.
*
* @see {@link OnRequestEndHooks}
* @see {@link OnRequestStartParameters}
* @see {@link OnRequestSuccessParameters}
* @see {@link OnRequestErrorParameters}
*/
type SoapQueryHook = (hookParameters: OnRequestStartParameters) => undefined | OnRequestEndHooks | Promise<OnRequestEndHooks>;
type HookParameters = {
/**
* The name of the service executing the query.
*/
service: string;
/**
* The name of the query being executed.
*/
query: string;
};
type OnRequestStartParameters = HookParameters & {
input: unknown;
};
type OnRequestSuccessParameters = HookParameters & {
response: unknown;
};
type OnRequestErrorParameters = HookParameters & {
error: Error;
};
type OnRequestEndHooks = {
onRequestSuccess?: (hookParameters: OnRequestSuccessParameters) => Promise<void> | void;
onRequestError?: (hookParameters: OnRequestErrorParameters) => Promise<void> | void;
};
declare function createHook(hookFn: SoapQueryHook): SoapQueryHook;
//#endregion
export { SoapQueryHook, createHook };
//# sourceMappingURL=hooks.d.mts.map