{
  "schemaVersion": 1,
  "source": "https://www.npmjs.com/package/jira.js/v/5.4.0",
  "about": "The unchanged jira.js 5.4.0 Version3Client, constructed as Twin's on-call agent (cookbook/on-call-agent/agent.mjs) constructs it: the site's URL and account email the World's credential door issues as JIRA_URL and JIRA_EMAIL, with Basic authentication by its JIRA_API_TOKEN. It reads the token's account (myself.getCurrentUser), makes the OPS project that account leads, files the agent's Task with its ADF description and High priority through the agent's own createIssue call, opens the ticket and checks every field it filed, and draws the 404 HttpException of a key no issue carries. Readback reads the ticket and the project again without writing.",
  "files": {
    "package.json": "{\n  \"name\": \"oncall-jira-customer\",\n  \"private\": true,\n  \"type\": \"module\",\n  \"dependencies\": {\n    \"jira.js\": \"5.4.0\"\n  }\n}\n",
    ".env.example": "JIRA_API_TOKEN=\nJIRA_EMAIL=\nJIRA_URL=\n",
    "app.mjs": "import assert from 'node:assert/strict';\nimport { writeFileSync } from 'node:fs';\nimport { HttpException, Version3Client } from 'jira.js';\nassert.ok(process.env.VOLTER_WORLD, 'Run the app through its World');\nassert.ok(process.env.JIRA_API_TOKEN && process.env.JIRA_EMAIL && process.env.JIRA_URL, 'The World issues the account API token, email and site URL');\n// As Twin's on-call agent constructs it: the site's URL, Basic authentication by the account's email and API token\nconst jira = new Version3Client({ host: process.env.JIRA_URL, authentication: { basic: { email: process.env.JIRA_EMAIL, apiToken: process.env.JIRA_API_TOKEN } } });\n\n// The token's own account, whose accountId leads the OPS project the agent files into\nconst me = await jira.myself.getCurrentUser();\nassert.equal(me.emailAddress, process.env.JIRA_EMAIL);\nassert.ok(me.accountId, 'the account has an accountId');\nconst project = await jira.projects.createProject({ key: 'OPS', name: 'Operations', projectTypeKey: 'software', leadAccountId: me.accountId });\nassert.equal(project.key, 'OPS');\n\n// The agent's call, unchanged: a Task with an ADF description and the triaged priority\nconst verdict = 'SEVERITY: high \u2014 checkout fails on Safari after the payment step';\nconst ticket = await jira.issues.createIssue({\n  fields: { project: { key: 'OPS' }, issuetype: { name: 'Task' }, summary: 'world/web#1: Checkout fails on Safari', description: { version: 1, type: 'doc', content: [{ type: 'paragraph', content: [{ type: 'text', text: verdict }] }] }, priority: { name: 'High' } },\n});\nassert.match(String(ticket.key), /^OPS-\\d+$/);\nassert.ok(String(ticket.self).endsWith(`/rest/api/3/issue/${ticket.id}`));\n\n// The filed ticket as the on-call engineer opens it\nconst read = await jira.issues.getIssue({ issueIdOrKey: ticket.key, fields: ['summary', 'description', 'priority', 'issuetype', 'status', 'project'] });\nassert.equal(read.key, ticket.key);\nassert.equal(read.fields.summary, 'world/web#1: Checkout fails on Safari');\nassert.equal(read.fields.priority.name, 'High');\nassert.equal(read.fields.issuetype.name, 'Task');\nassert.equal(read.fields.project.key, 'OPS');\nassert.equal(read.fields.status.name, 'To Do');\nassert.equal(read.fields.description.type, 'doc');\nassert.equal(read.fields.description.content[0].content[0].text, verdict);\n// A ticket key no issue carries is refused, and the client throws its HttpException with the status\nawait assert.rejects(() => jira.issues.getIssue({ issueIdOrKey: 'OPS-999' }), (e) => e instanceof HttpException && e.status === 404);\n\nconst receipt = { project: project.key, ticket: ticket.key, id: ticket.id, verdict };\nwriteFileSync('first-use-receipt.json', JSON.stringify(receipt, null, 2) + '\\n');\nconsole.log(JSON.stringify(receipt));\n",
    "resume.mjs": "import assert from 'node:assert/strict';\nimport { readFileSync } from 'node:fs';\nimport { Version3Client } from 'jira.js';\nassert.ok(process.env.VOLTER_WORLD, 'Run the app through its World');\nconst prior = JSON.parse(readFileSync('first-use-receipt.json', 'utf8'));\nconst jira = new Version3Client({ host: process.env.JIRA_URL, authentication: { basic: { email: process.env.JIRA_EMAIL, apiToken: process.env.JIRA_API_TOKEN } } });\nconst read = await jira.issues.getIssue({ issueIdOrKey: prior.ticket, fields: ['summary', 'description', 'priority'] });\nassert.equal(read.id, prior.id);\nassert.equal(read.fields.summary, 'world/web#1: Checkout fails on Safari');\nassert.equal(read.fields.priority.name, 'High');\nassert.equal(read.fields.description.content[0].content[0].text, prior.verdict);\nconst projects = await jira.projects.searchProjects({});\nassert.ok(projects.values.some((p) => p.key === prior.project), 'the OPS project is retained');\nconsole.log(JSON.stringify({ retained: true, ticket: read.key, priority: read.fields.priority.name }));\n"
  },
  "run": [
    "node",
    "app.mjs"
  ],
  "retention": {
    "readback": [
      "node",
      "resume.mjs"
    ]
  }
}
