@dgac/nmb2b-client
Version:
EUROCONTROL Network Manager B2B SOAP client
1 lines • 1.51 kB
Source Map (JSON)
{"version":3,"file":"hooks.mjs","names":[],"sources":["../../../src/utils/hooks/hooks.ts"],"sourcesContent":["/**\n * A hook that will be executed when a query starts.\n *\n * A hook can return an object with optional properties :\n * - `onRequestSuccess`: a hook executed when the query is successful\n * - `onRequestError`: a hook executed when the query fails\n *\n * All hooks can be sync or async.\n *\n * @see {@link OnRequestEndHooks}\n * @see {@link OnRequestStartParameters}\n * @see {@link OnRequestSuccessParameters}\n * @see {@link OnRequestErrorParameters}\n */\nexport type SoapQueryHook = (\n hookParameters: OnRequestStartParameters,\n) => undefined | OnRequestEndHooks | Promise<OnRequestEndHooks>;\n\ntype HookParameters = {\n /**\n * The name of the service executing the query.\n */\n service: string;\n\n /**\n * The name of the query being executed.\n */\n query: string;\n};\n\ntype OnRequestStartParameters = HookParameters & { input: unknown };\n\ntype OnRequestSuccessParameters = HookParameters & { response: unknown };\n\ntype OnRequestErrorParameters = HookParameters & { error: Error };\n\ntype OnRequestEndHooks = {\n onRequestSuccess?: (\n hookParameters: OnRequestSuccessParameters,\n ) => Promise<void> | void;\n onRequestError?: (\n hookParameters: OnRequestErrorParameters,\n ) => Promise<void> | void;\n};\n\nexport function createHook(hookFn: SoapQueryHook): SoapQueryHook {\n return hookFn;\n}\n"],"mappings":";AA6CA,SAAgB,WAAW,QAAsC;AAC/D,QAAO"}