/** * @license * @preserve * * Copyright 2026 KeeeX SAS * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in * the Software without restriction, including without limitation the rights to * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies * of the Software, and to permit persons to whom the Software is furnished to do * so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in all * copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. * */ import { type AuthenticationMethod } from "./auth.js"; import { type ProgressHandlers } from "./progress.js"; import { type ValidateStatus } from "./status.js"; import type * as apifile from "./apifile.js"; import type * as hook from "./hook.js"; import type * as pagination from "./pagination.js"; import type * as utiltype from "@keeex/utils/types/types.js"; import type * as axios from "axios"; /** Convert from one type to another. */ export type DataFilter = (input: Input) => utiltype.Awaitable; /** Base parameters for all API calls */ export interface DefBase { /** Add authentication data */ authentication?: AuthenticationMethod; /** Override `baseUrl` from the main config */ baseUrl?: string; hooks?: hook.Hooks; /** HTTP method */ method: axios.Method; /** Disable global hooks for this route */ disableGlobalHooks?: boolean | hook.DisableHooks; /** * Queue name. * * Requests from different queues will be executed in parallel. */ queue?: string; /** * Predicate to apply to the response. * * If it fails, the error propagate as if it was a request error. */ responsePredicate?: utiltype.TypePredicate; /** * Route to append to the base URL. * * Route parameters are declared with a `:` prefix */ route: string; /** * HTTP status value that are accepted as valid. * * Defaults to accepting any 2XX status. */ validateStatus?: ValidateStatus; } /** Used as a replacement type for `headersParams` and `queryParams` */ export type GenericKeyBasedArray = Array | Set | undefined; export interface JsonInProps { /** Input values to put in headers */ headersParams?: Array | Set; /** Convert the JavaScript data into JSON data */ inputFilter?: DataFilter; /** * Sending a `multipart/form-data` body. * * If `true`, always send a `multipart/form-data`. * If `false`, or undefined, always send a JSON object. * * If a file is specified while `multipart` is set to `false`, the file will be encoded in a JSON * object with the `ApiFileJson` interface. * If a file is specified and `multipart` is `undefined`, throw an error. */ multipart?: boolean; /** Properties to put in the query part of the URL */ queryParams?: Array | Set; } export interface JsonOutProps { /** Convert the JSON data into a JavaScript object */ outputFilter?: DataFilter; } /** Response with details */ export interface FullResponse { data: OutputType; httpCode: number; responseHeaders: axios.AxiosHeaders; } /** Response with details */ export interface FullNoResponse { httpCode: number; responseHeaders: axios.AxiosHeaders; } /** Definition of API call NoInNoOut */ export type DefNoInNoOut = DefBase; /** API call that takes no input, and produce no output */ export type NoInNoOutFn = (progress?: ProgressHandlers) => Promise; /** Definition of API call JsonInJsonOut */ export interface DefJsonInJsonOut extends DefBase, JsonInProps, JsonOutProps { } /** API call that takes a JSON in, and gets a JSON out */ export type JsonInJsonOutFn = (input: InputType, progress?: ProgressHandlers) => Promise; /** Definition of API call NoInJsonOut */ export interface DefNoInJsonOut extends DefBase, JsonOutProps { } /** API call that takes no input and gets a JSON out */ export type NoInJsonOutFn = (progress?: ProgressHandlers) => Promise; /** Definition of API call JsonInNoOut */ export interface DefJsonInNoOut extends DefBase, JsonInProps { } /** API call that takes a JSON in and produce no output */ export type JsonInNoOutFn = (input: InputType, progress?: ProgressHandlers) => Promise; export interface DefPaginatedJsonInJsonOut extends Omit>, "responsePredicate">, JsonInProps, JsonOutProps { extraPropsPredicate?: utiltype.TypePredicate; /** Convert custom top-level props from the response */ extraPropsFilter?: DataFilter; responsePredicate?: utiltype.TypePredicate; /** Check that the value of `SortKeys` are correct (defaults to `isString()`) */ sortKeysPredicate?: utiltype.TypePredicate; } /** API call that takes a JSON in, and gets a paginated JSON out */ export type PaginatedJsonInJsonOutFn = (input: pagination.PaginationInputType, progress?: ProgressHandlers) => Promise; /** Definition of API call JsonInBinOut */ export interface DefJsonInBinOut extends DefBase, JsonInProps { } /** API call that takes a JSON in, and return a byte buffer */ export type JsonInBinOutFn = (input: InputType, progress?: ProgressHandlers) => Promise; /** Definition of API call NoInBinOut */ export type DefNoInBinOut = DefBase; /** Call with no input and a file output */ export type NoInBinOutFn = (progress?: ProgressHandlers) => Promise; /** Definition of API call binInJsonOut */ export interface DefBinInJsonOut extends DefBase, JsonOutProps { } /** API call that takes a file input, and gets a JSON out */ export type BinInJsonOutFn = (input: apifile.SendableFile, headers?: Record, progress?: ProgressHandlers) => Promise; /** Definition of API call binInBinOut */ export type DefBinInBinOut = DefBase; /** API call that takes a byte buffer input, and return a byte buffer */ export type BinInBinOutFn = (input: apifile.SendableFile, headers?: Record, progress?: ProgressHandlers) => Promise; /** Definition of API call binInNoOut */ export type DefBinInNoOut = DefBase; export type BinInNoOutFn = (input: apifile.SendableFile, headers?: Record, progress?: ProgressHandlers) => Promise;