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3B,CAOF,CAAC,SAAA,wBAEuB,GACtB,IAAM,EAA4B,CAAC,EAMnC,OAJA,EAAQ,MAAM,SAAS,IACrB,EAAI,EAAE,KAAO,EAAE,KAAK,IAGf,OAAO,KAAK,KAAK,UAAU,EAAK,KAAM,GAAI,QACnD,CAAC,SAAA,QAEO,GACN,OAAO,EAAI,QAAQ,KAAM,IAAI,QAAQ,KAAM,IAAI,QAAQ,IAAK,IAC9D,CAAC,IAAA,SAAA,QAAA,QAGY,eAAc,OAAA,gBAAA","file":"/npm/newman-reporter-allure@3.4.3/dist/cjs/index.js","sourceRoot":"","sourcesContent":["/**\n * Minified by jsDelivr using Terser v5.39.0.\n * Original file: /npm/newman-reporter-allure@3.4.3/dist/cjs/index.js\n *\n * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files\n */\n","/* eslint-disable @typescript-eslint/unbound-method */\nimport type { EventEmitter } from \"events\";\nimport type { ConsoleEvent, Cursor, NewmanRunExecutionAssertion } from \"newman\";\nimport type { CollectionDefinition, Event, HeaderList, Item, Request, Response } from \"postman-collection\";\nimport { ContentType, Stage, Status } from \"allure-js-commons\";\nimport type { ReporterConfig } from \"allure-js-commons/sdk/reporter\";\nimport {\n  ReporterRuntime,\n  createDefaultWriter,\n  getEnvironmentLabels,\n  getFrameworkLabel,\n  getHostLabel,\n  getLanguageLabel,\n  getSuiteLabels,\n  getThreadLabel,\n} from \"allure-js-commons/sdk/reporter\";\nimport type { PmItem, RunningItem } from \"./model.js\";\nimport { extractMeta } from \"./utils.js\";\n\nclass AllureReporter {\n  allureRuntime: ReporterRuntime;\n  allureConfig: ReporterConfig;\n  runningItems: RunningItem[] = [];\n  currentCollection: CollectionDefinition;\n  pmItemsByAllureUuid: Map<string, PmItem> = new Map();\n  currentTest?: string;\n  currentScope?: string;\n  rootCollectionName?: string;\n\n  constructor(\n    emitter: EventEmitter,\n    reporterConfig: ReporterConfig,\n    options: {\n      collection: CollectionDefinition;\n    },\n  ) {\n    const { resultsDir, ...restConfig } = reporterConfig;\n\n    this.currentCollection = options.collection;\n    this.rootCollectionName = options.collection.name;\n    this.allureConfig = reporterConfig;\n    this.allureRuntime = new ReporterRuntime({\n      ...restConfig,\n      writer: createDefaultWriter({ resultsDir, emitter }),\n    });\n    this.registerEvents(emitter);\n  }\n\n  registerEvents(emitter: EventEmitter) {\n    emitter.on(\"start\", this.onStart.bind(this));\n    emitter.on(\"beforeItem\", this.onBeforeItem.bind(this));\n    emitter.on(\"item\", this.onItem.bind(this));\n    emitter.on(\"prerequest\", this.onPrerequest.bind(this));\n    emitter.on(\"request\", this.onRequest.bind(this));\n    emitter.on(\"test\", this.onTest.bind(this));\n    emitter.on(\"assertion\", this.onAssertion.bind(this));\n    emitter.on(\"console\", this.onConsole.bind(this));\n    emitter.on(\"done\", this.onDone.bind(this));\n  }\n\n  onStart() {\n    this.currentScope = this.allureRuntime.startScope();\n  }\n\n  onPrerequest(\n    err: any,\n    args: {\n      executions: Event[];\n    },\n  ) {\n    if (!this.currentTest) {\n      return;\n    }\n\n    const currentPmItem = this.pmItemsByAllureUuid.get(this.currentTest);\n\n    if (!currentPmItem) {\n      return;\n    }\n\n    currentPmItem.prerequest = args.executions[0]?.script?.exec?.join(\"\\n\");\n  }\n\n  onBeforeItem(err: any, args: { item: Item; cursor: Cursor }) {\n    const pmItem: PmItem = {\n      name: args.item.name,\n      passed: true,\n      failedAssertions: [],\n      consoleLogs: [],\n    };\n    const itemGroup = args.item.parent();\n    const item = args.item;\n    const fullName = this.#getFullName(item);\n    const testPath = this.#pathToItem(item);\n    const hostLabel = getHostLabel();\n    const threadLabel = getThreadLabel();\n    const { labels, links } = extractMeta(args.item.events);\n\n    this.currentTest = this.allureRuntime.startTest({\n      name: args.item.name,\n      fullName,\n      titlePath: testPath,\n      stage: Stage.RUNNING,\n      labels: [\n        getLanguageLabel(),\n        getFrameworkLabel(\"newman\"),\n        hostLabel,\n        threadLabel,\n        ...labels,\n        ...getEnvironmentLabels(),\n      ],\n      links,\n    });\n\n    this.allureRuntime.updateTest(this.currentTest, (test) => {\n      test.labels.push(...getSuiteLabels(testPath));\n    });\n\n    this.pmItemsByAllureUuid.set(this.currentTest, pmItem);\n\n    if (itemGroup && this.currentCollection !== itemGroup) {\n      this.currentCollection = itemGroup;\n    }\n  }\n\n  onItem(\n    err: any,\n    args: {\n      item: Item;\n    },\n  ) {\n    if (!this.currentTest) {\n      return;\n    }\n\n    const currentPmItem = this.pmItemsByAllureUuid.get(this.currentTest);\n\n    if (!currentPmItem) {\n      return;\n    }\n\n    const requestData = currentPmItem.requestData;\n    const requestDataURL = requestData && `${requestData.method} - ${requestData.url}`;\n    const rawDescription = args.item.request.description;\n    const testDescription = (typeof rawDescription === \"string\" ? rawDescription : rawDescription?.content) || \"\";\n    const response = currentPmItem.responseData;\n    const failedAssertions = currentPmItem.failedAssertions;\n    const requestError = currentPmItem.requestError;\n\n    if (currentPmItem.prerequest) {\n      this.#attachString(\"PreRequest\", currentPmItem.prerequest);\n    }\n\n    if (currentPmItem.testScript) {\n      this.#attachString(\"TestScript\", currentPmItem.testScript);\n    }\n\n    if (currentPmItem.consoleLogs.length) {\n      this.#attachString(\"ConsoleLogs\", currentPmItem.consoleLogs);\n    }\n\n    if (requestData?.headers && requestData?.headers?.count() > 0) {\n      this.allureRuntime.writeAttachment(\n        this.currentTest,\n        undefined,\n        \"Request Headers\",\n        this.#headerListToJsonBuffer(requestData.headers),\n        {\n          contentType: ContentType.JSON,\n        },\n      );\n    }\n\n    if (requestData?.body?.mode === \"raw\" && requestData.body.raw) {\n      this.#attachString(\"Request Body\", requestData.body.raw);\n    }\n\n    if (response?.headers && response?.headers?.count() > 0) {\n      this.allureRuntime.writeAttachment(\n        this.currentTest,\n        undefined,\n        \"Response Headers\",\n        this.#headerListToJsonBuffer(response.headers),\n        {\n          contentType: ContentType.JSON,\n        },\n      );\n    }\n\n    if (response?.body) {\n      this.allureRuntime.writeAttachment(\n        this.currentTest,\n        undefined,\n        \"Response Body\",\n        Buffer.from(response.body, \"utf-8\"),\n        {\n          contentType: ContentType.TEXT,\n        },\n      );\n    }\n\n    this.allureRuntime.updateTest(this.currentTest, (test) => {\n      if (requestDataURL) {\n        test.parameters.push({\n          name: \"Request\",\n          value: requestDataURL,\n        });\n      }\n\n      if (response?.code) {\n        test.parameters.push({\n          name: \"Response Code\",\n          value: response?.code.toString(),\n          excluded: true,\n        });\n      }\n\n      if (testDescription) {\n        const descriptionHtml = testDescription.replace(/[*]/g, \"\").replace(/\\n/g, \"<br>\");\n\n        test.description = testDescription;\n        test.descriptionHtml = descriptionHtml;\n      }\n    });\n\n    if (response && failedAssertions?.length) {\n      const details = this.#escape(`Response code: ${response.code}, status: ${response.status}`);\n\n      this.allureRuntime.updateTest(this.currentTest, (test) => {\n        test.status = Status.FAILED;\n        test.stage = Stage.FINISHED;\n        test.statusDetails = {\n          message: this.#escape(failedAssertions.join(\", \")),\n          trace: details,\n        };\n      });\n    } else if (requestError) {\n      const errorMsg = this.#escape(requestError);\n\n      this.allureRuntime.updateTest(this.currentTest, (test) => {\n        test.status = Status.BROKEN;\n        test.stage = Stage.FINISHED;\n        test.statusDetails = {\n          message: errorMsg,\n        };\n      });\n    } else {\n      this.allureRuntime.updateTest(this.currentTest, (test) => {\n        test.status = Status.PASSED;\n        test.stage = Stage.FINISHED;\n      });\n    }\n\n    this.allureRuntime.stopTest(this.currentTest);\n    this.allureRuntime.writeTest(this.currentTest);\n  }\n\n  onTest(err: any, args: { executions: Event[] }) {\n    if (!this.currentTest) {\n      return;\n    }\n\n    const currentPmItem = this.pmItemsByAllureUuid.get(this.currentTest);\n\n    if (!currentPmItem) {\n      return;\n    }\n\n    const execScript = args.executions[0]?.script?.exec?.join(\"\\n\");\n\n    if (!execScript) {\n      return;\n    }\n\n    currentPmItem.testScript = execScript;\n\n    // not typed postman-collection error property ?\n    const testArgs: any = args.executions[0];\n\n    if (!testArgs.error) {\n      return;\n    }\n\n    const errName: string = testArgs.error.name;\n    const errMsg: string = testArgs.error.message;\n\n    const stepUuid = this.allureRuntime.startStep(this.currentTest, undefined, {\n      name: errName,\n      status: Status.FAILED,\n      stage: Stage.FINISHED,\n      statusDetails: {\n        message: errMsg,\n      },\n    });\n\n    if (!stepUuid) {\n      // no such test running, ignore reporting\n      return;\n    }\n\n    currentPmItem.failedAssertions.push(errName);\n\n    this.allureRuntime.stopStep(stepUuid);\n  }\n\n  onConsole(err: any, args: ConsoleEvent) {\n    if (!this.currentTest) {\n      return;\n    }\n\n    const currentPmItem = this.pmItemsByAllureUuid.get(this.currentTest);\n\n    if (!currentPmItem || err) {\n      return;\n    }\n\n    if (args.level) {\n      currentPmItem.consoleLogs.push(`level: ${args.level}, messages: ${args.messages.toString()}`);\n    }\n  }\n\n  onRequest(\n    err: any,\n    args: {\n      request: Request;\n      response: Response;\n    },\n  ) {\n    if (!this.currentTest) {\n      return;\n    }\n\n    const currentPmItem = this.pmItemsByAllureUuid.get(this.currentTest);\n\n    if (!currentPmItem) {\n      return;\n    }\n\n    const req = args.request;\n    const url = req.url.toString(true);\n\n    currentPmItem.requestData = {\n      url: url,\n      method: req.method,\n      body: req.body,\n      headers: req.headers,\n    };\n\n    if (err) {\n      currentPmItem.passed = false;\n      currentPmItem.requestError = err.message;\n    }\n\n    if (!args.response) {\n      return;\n    }\n\n    const respStream = args?.response?.stream;\n    const respBody = respStream ? Buffer.from(respStream).toString() : \"\";\n\n    currentPmItem.responseData = {\n      status: args.response.status,\n      code: args.response.code,\n      body: respBody,\n      headers: args.response.headers,\n    };\n  }\n\n  onAssertion(err: any, args: NewmanRunExecutionAssertion) {\n    if (!this.currentTest) {\n      return;\n    }\n\n    const currentPmItem = this.pmItemsByAllureUuid.get(this.currentTest);\n\n    if (!currentPmItem) {\n      return;\n    }\n\n    const stepUuid = this.allureRuntime.startStep(this.currentTest, undefined, {\n      name: args.assertion,\n    });\n    if (!stepUuid) {\n      // no such test running, ignore reporting\n      return;\n    }\n\n    this.allureRuntime.updateStep(stepUuid, (step) => {\n      if (err && currentPmItem) {\n        currentPmItem.passed = false;\n        currentPmItem.failedAssertions.push(args.assertion);\n\n        step.statusDetails = {\n          message: err.message,\n          trace: err.stack,\n        };\n        step.status = Status.FAILED;\n      } else {\n        step.status = Status.PASSED;\n      }\n\n      step.stage = Stage.FINISHED;\n    });\n\n    this.allureRuntime.stopStep(stepUuid);\n  }\n\n  onDone() {\n    if (this.currentScope) {\n      this.allureRuntime.writeScope(this.currentScope);\n      this.currentScope = undefined;\n    }\n  }\n\n  #pathToItem(item: Item): string[] {\n    if (!item || !(typeof item.parent === \"function\") || !(typeof item.forEachParent === \"function\")) {\n      return [];\n    }\n\n    const chain: string[] = [];\n\n    item.forEachParent((parent) => {\n      // eslint-disable-next-line @typescript-eslint/no-unsafe-argument\n      chain.unshift(parent.name || parent.id);\n    });\n\n    if (this.rootCollectionName) {\n      chain.unshift(this.rootCollectionName);\n    }\n    return chain;\n  }\n\n  #getFullName(item: Item): string {\n    const chain = this.#pathToItem(item);\n\n    return `${chain.join(\"/\")}#${item.name}`;\n  }\n\n  #attachString(name: string, value: string | string[]) {\n    const stringToAttach = Array.isArray(value) ? value.join(\"\\n\") : value;\n\n    if (!stringToAttach) {\n      return;\n    }\n\n    const content = Buffer.from(stringToAttach, \"utf-8\");\n\n    this.allureRuntime.writeAttachment(this.currentTest!, undefined, name, content, {\n      contentType: ContentType.TEXT,\n    });\n  }\n\n  #headerListToJsonBuffer(headers: HeaderList) {\n    const ret: { [k: string]: any } = {};\n\n    headers.all().forEach((h) => {\n      ret[h.key] = h.value;\n    });\n\n    return Buffer.from(JSON.stringify(ret, null, 4), \"utf-8\");\n  }\n\n  #escape(val: string) {\n    return val.replace(\"\\n\", \"\").replace(\"\\r\", \"\").replace('\"', '\"');\n  }\n}\n\nexport default AllureReporter;\n"]}