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AAkB,CAAA,EAAA,GAAM;AACxB,EAAA,MAAM,IAAI,KAAA,CAAM,6BAA6B,CAAA;AACjD,CAAC,CAAA;AAKL,IAAM,4BAAA,EAA8B,0BAAA;AAAA,EAChC,yKAAA;AAAA,EACA;AAAA,IACI,OAAA,EAAS,EAAE,cAAA,EAAgB,mBAAmB,CAAA;AAAA,IAC9C,MAAA,EAAQ;AAAA,EACZ;AACJ,CAAA;AAKA,IAAM,0CAAA,EAA4C,0BAAA;AAAA,EAC9C,uEAAA;AAAA,EACA,EAAE,MAAA,EAAQ,IAAI;AAClB,CAAA;AAKA,IAAM,kCAAA,EAAoC,0BAAA;AAAA,EACtC,qFAAA;AAAA,EAEA,EAAE,MAAA,EAAQ,IAAI;AAClB,CAAA;AAKA,IAAM,gCAAA,EAAkC,0BAAA;AAAA,EACpC,kCAAA;AAAA,EACA,EAAE,MAAA,EAAQ,IAAI;AAClB,CAAA;AAkBA,IAAM,kBAAA,EAAkC,CAAC,IAAA,EAAA,GAAwB;AAC7D,EAAA,MAAM,IAAI,KAAA,CAAM,CAAA,mCAAA,EAAsC,IAAI,CAAA,CAAA;AAC9D;AAuBiE;ADxIJ;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA","file":"/home/runner/work/funpara/funpara/build/index.cjs","sourcesContent":[null,"/* eslint-disable @typescript-eslint/naming-convention */\n\n// Date related types and functions\n\n/**\n * Type for a function that returns a Date.\n */\ntype DateFunction = () => Date\n\n/**\n * Returns a DateFunction that returns the current date.\n * Can for example be used to get the current date when logging.\n * @returns DateFunction function returning the current data\n */\nfunction nowDateFunction(): DateFunction {\n    return (): Date => new Date()\n}\n\n/**\n * Returns a DateFunction that returns a fixed date.\n * Can for example be used to get a fixed date for testing.\n * @param dateString fixed date string\n * @returns DateFunction function returning the fixed date\n */\nfunction fixedDateFunction(dateString: string): DateFunction {\n    return (): Date => new Date(dateString)\n}\n\n/**\n * Test date\n * '1001-01-01T00:00:00.000Z'\n * as ISO Date string. Can be used to ease and unify testing.\n */\nconst testDateString = '1001-01-01T00:00:00.000Z'\n\n/**\n * DateFunction that returns the test date.\n * Can for example be used to always get the date when testing.\n */\nconst testDateFunction: DateFunction = fixedDateFunction(testDateString)\n\n// Fetch related types and functions\n\n/**\n * Type for a fetch function that given an input (url, request, etc.) and request init\n * returns a Promise<Response>\n */\ntype FetchFunction = (\n    input: string | URL | Request,\n    init?: RequestInit,\n) => Promise<Response>\n\n/**\n * Returns a FetchFunction that always returns a fixed response.\n * Can for example be used to get a fixed Response for testing.\n * @param bodyInit body for the response\n * @param init response init\n * @returns FetchFunction function returning the fixed Response\n */\nfunction fixedResponseFetchFunction(\n    bodyInit?: BodyInit,\n    init?: ResponseInit,\n): FetchFunction {\n    return (): Promise<Response> =>\n        Promise.resolve(new Response(bodyInit, init))\n}\n\n/**\n * FetchFunction that returns a fixed Response with and empty body and status 400 (Bad Request).\n */\nconst badRequestFetchFunction = fixedResponseFetchFunction(undefined, {\n    status: 400,\n})\n\n/**\n * FetchFunction that returns a fixed Response with and empty body and status 404 (Not Found).\n */\nconst notFoundFetchFunction: FetchFunction = fixedResponseFetchFunction(\n    undefined,\n    { status: 404 },\n)\n\n/**\n * FetchFunction that returns a fixed Response with and empty body and status 500 (Internal Server Error).\n */\nconst internalServerErrorFetchFunction = fixedResponseFetchFunction(undefined, {\n    status: 500,\n})\n\n/**\n * FetchFunction that returns a fixed Response with broken JSON (missing bracket)\n */\nconst brokenJSONFetchFunction: FetchFunction = fixedResponseFetchFunction(\n    '{\"data\": {\"message\": \"Missing bracket\"}',\n    {\n        headers: { 'Content-Type': 'application/json' },\n        status: 200,\n    },\n)\n\n/**\n * FetchFunction that returns a fixed Response with an unknown\n * Content-Type ('application/unknown')\n */\nconst unknownContentTypeFetchFunction: FetchFunction =\n    fixedResponseFetchFunction(undefined, {\n        headers: { 'Content-Type': 'application/unknown' },\n        status: 200,\n    })\n\n/**\n * FetchFunction that returns a fixed Response that throws a Timeout error.\n */\nconst timeoutFetchFunction: FetchFunction = (): Promise<Response> =>\n    new Promise<Response>(() => {\n        throw new Error('Connection failed ETIMEDOUT')\n    })\n\n/**\n * FetchFunction that returns a fixed Response with an AggregateError.\n */\nconst aggregateErrorFetchFunction = fixedResponseFetchFunction(\n    '{\"errors\":[{\"message\":\"aaa The first error!, The second error!\", \"originalError\": {\"errors\": [{\"message\":\"The first error!\"}, {\"message\":\"The second error!\"}  ] }  }]}',\n    {\n        headers: { 'Content-Type': 'application/json' },\n        status: 200,\n    },\n)\n\n/**\n * FetchFunction that returns a fixed Response that GraphQL introspection is disabled.\n */\nconst graphQLIntrospectionDisabledFetchFunction = fixedResponseFetchFunction(\n    '{\"errors\": [ { \"message\": \"Introspection is disabled\"}],\"data\": null}',\n    { status: 200 },\n)\n\n/**\n * FetchFunction that returns a fixed Response with an invalid GraphQL schema.\n */\nconst graphQLInvalidSchemaFetchFunction = fixedResponseFetchFunction(\n    '{\"data\": {\"__schema\":\"NotAGraphQLSchema\", ' +\n        '\"_service\": {\"sdl\":\"NotAGraphQLSchema\"}}}',\n    { status: 200 },\n)\n\n/**\n * FetchFunction that returns a fixed Response with an invalid GraphQL body.\n */\nconst graphQLInvalidBodyFetchFunction = fixedResponseFetchFunction(\n    '{\"message\": \"I am not GraphQL!\"}',\n    { status: 200 },\n)\n\n// Exit function related types and functions\n\n/**\n * Type for a function that given an exit does not return anything.\n * @param {number} code The exit code to use\n * @returns {never} Does not return anything, may e.g. exit the process or throw an error\n */\ntype ExitFunction = (code: number) => never\n\n/**\n * Exit function that does not exit the process but throws an error instead\n * Can be used in testing to avoid the tests exiting the application.\n * @param {number} code The exit code to be thrown in the error\n * @returns {never} Does not return anything but throws an error with the message\n * \"Exit function was called with code CODE\" where CODE is the given code.\n */\nconst doNotExitFunction: ExitFunction = (code: number): never => {\n    throw new Error(`Exit function was called with code ${code}`)\n}\n\n// Timeout function related types and functions\n\n/**\n * Type for a function that given a TimerHandler, optional timeout and arguments returns the timeout ID as number.\n * @param {TimerHandler} handler The TimerHandler to be called (i.e. in most cases a callback function)\n * @param {number} timeout The timeout in milliseconds\n * @param {any[]} timeoutArguments The arguments to be passed to the handler\n * @returns {number} The timeout ID as number\n */\ntype TimeoutFunction = (\n    handler: TimerHandler,\n    timeout?: number,\n    // eslint-disable-next-line @typescript-eslint/no-explicit-any\n    ...timeoutArguments: any[]\n) => number\n\n/**\n * TimeoutFunction that does not call the callback function but returns a fixed timeout ID 1.\n * Can be used in testing to avoid the tests waiting for the timeout to finish.\n * @returns {number} Fixed timeout ID 1\n */\nconst noCallbackTimeoutFunction: TimeoutFunction = (): number => 1\n\nexport {\n    aggregateErrorFetchFunction,\n    badRequestFetchFunction,\n    brokenJSONFetchFunction,\n    doNotExitFunction,\n    fixedDateFunction,\n    fixedResponseFetchFunction,\n    graphQLIntrospectionDisabledFetchFunction,\n    graphQLInvalidBodyFetchFunction,\n    graphQLInvalidSchemaFetchFunction,\n    internalServerErrorFetchFunction,\n    noCallbackTimeoutFunction,\n    notFoundFetchFunction,\n    nowDateFunction,\n    testDateFunction,\n    testDateString,\n    timeoutFetchFunction,\n    unknownContentTypeFetchFunction,\n}\n\nexport type { DateFunction, ExitFunction, FetchFunction, TimeoutFunction }\n"]}