{"_id":"@bleed-believer/ssrs","name":"@bleed-believer/ssrs","dist-tags":{"latest":"0.0.0"},"versions":{"0.0.0":{"name":"@bleed-believer/ssrs","type":"module","version":"0.0.0","description":"Render reports from SQL Server Reporting Services (SSRS) using NTLM or Basic authentication. Zero runtime dependencies.","keywords":["ssrs","ntlm","ntlmv2","report","reporting-services","sql-server","url-access"],"license":"MIT","author":{"name":"sleep-written"},"repository":{"type":"git","url":"git+https://github.com/sleep-written/bleed-believer-ssrs.git"},"bugs":{"url":"https://github.com/sleep-written/bleed-believer-ssrs/issues"},"homepage":"https://github.com/sleep-written/bleed-believer-ssrs#readme","engines":{"node":">=20"},"main":"./dist/index.js","types":"./dist/index.d.ts","exports":{".":{"types":"./dist/index.d.ts","default":"./dist/index.js"}},"scripts":{"build:clear":"rm -rf dist","build:bleed":"bleed build --config ./tsconfig.build.json","build:tscdf":"tsc -p tsconfig.build.json","build":"node --run build:clear && node --run build:bleed && node --run build:tscdf","watch":"bleed build --config ./tsconfig.build.json --watch","start":"bleed start ./src/index.ts --","test":"node --import @bleed-believer/cli --test --"},"devDependencies":{"@bleed-believer/cli":"^1.0.2","@types/node":"^25.9.2","typescript":"^6.0.3"},"gitHead":"5c3d0b5b993267226a9894362c9214d747b97806","_id":"@bleed-believer/ssrs@0.0.0","_nodeVersion":"24.16.0","_npmVersion":"11.16.0","dist":{"integrity":"sha512-brKZfFa54Q1WFGwB530H1n9w6vnerHib1YbSu5t9sXF8QSeYNmw6yG4ihe0iCTcrdrqSoi5d0CN4cBXjIPNgQw==","shasum":"f4643c03f09458926f892b5873eab8da902bc83b","tarball":"https://registry.npmjs.org/@bleed-believer/ssrs/-/ssrs-0.0.0.tgz","fileCount":85,"unpackedSize":44005,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIQCoX/3d1xbEja2v3PILh1ggnPchd4rpBX2KQrTGUccoRgIgLq6rfyFKbNBRRnqbPqJXozo6rxBVLtS2G2ziQeZwkBU="}]},"_npmUser":{"name":"sleep-written","email":"sleep.written0000@gmail.com"},"directories":{},"maintainers":[{"name":"sleep-written","email":"sleep.written0000@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/ssrs_0.0.0_1781119403610_0.8879397879571098"},"_hasShrinkwrap":false}},"time":{"created":"2026-06-10T19:23:23.395Z","0.0.0":"2026-06-10T19:23:23.764Z","modified":"2026-06-10T19:23:24.161Z"},"maintainers":[{"name":"sleep-written","email":"sleep.written0000@gmail.com"}],"description":"Render reports from SQL Server Reporting Services (SSRS) using NTLM or Basic authentication. Zero runtime dependencies.","homepage":"https://github.com/sleep-written/bleed-believer-ssrs#readme","keywords":["ssrs","ntlm","ntlmv2","report","reporting-services","sql-server","url-access"],"repository":{"type":"git","url":"git+https://github.com/sleep-written/bleed-believer-ssrs.git"},"author":{"name":"sleep-written"},"bugs":{"url":"https://github.com/sleep-written/bleed-believer-ssrs/issues"},"license":"MIT","readme":"# @bleed-believer/ssrs\n\nA TypeScript library for rendering reports from SQL Server Reporting Services (SSRS) using NTLM or Basic authentication. Zero runtime dependencies.\n\n## Installation\n\n```bash\nnpm install @bleed-believer/ssrs\n```\n\n## Usage\n\n```typescript\nimport { NTLMProtocol, SSRS } from '@bleed-believer/ssrs';\nimport { writeFile } from 'node:fs/promises';\n\nconst ntlm = new NTLMProtocol({\n    username: 'administrator',\n    password: 'your-password'\n});\n\nconst ssrs = new SSRS('http://your-server/ReportServer', ntlm);\nconst file = await ssrs.renderReport('/Reports/MyReport', 'PDF', {\n    startDate: new Date(2026, 0, 1),\n    endDate:   new Date(2026, 0, 31)\n});\n\nawait writeFile('./report.pdf', file.data);\n```\n\n### Parallel rendering\n\nEvery `renderReport` call is fully independent: each one opens its own dedicated\nconnection, performs its own NTLM handshake, and closes the connection when the\nresponse arrives. Nothing is shared between calls and no sockets are left open,\nso you can safely render multiple reports in parallel with a single instance:\n\n```typescript\nawait Promise.all([\n    ssrs.renderReport('/Reports/Sales',   'EXCELOPENXML', { year: 2026 })\n        .then(({ data }) => writeFile('./sales.xlsx', data)),\n    ssrs.renderReport('/Reports/Summary', 'PDF', { year: 2026 })\n        .then(({ data }) => writeFile('./summary.pdf', data)),\n]);\n```\n\n## API\n\n### `NTLMProtocol`\n\nHandles NTLM (NTLMv2) authentication against the SSRS server. The instance only\nholds the credentials; each request creates and disposes its own connection.\n\n```typescript\nconst ntlm = new NTLMProtocol({\n    username:    string,   // required\n    password:    string,   // required\n    domain?:     string,\n    workstation?: string\n});\n```\n\n#### `ntlm.fetch(input, init?)`\n\nA `fetch`-like method that transparently performs the NTLM handshake and returns\na standard `Response`. Supports `method`, `headers` and `body` (as `string`,\n`Buffer`, `TypedArray`, `ArrayBuffer` or `URLSearchParams`) from `RequestInit`.\nRedirects are not followed.\n\n```typescript\nconst resp = await ntlm.fetch('http://your-server/ReportServer?%2FReports%2FMyReport&rs:Format=PDF');\n```\n\n### `BasicProtocol`\n\nHTTP Basic authentication, for servers configured with `RSWindowsBasic`. Same\n`fetch`-like contract and the same connection model as `NTLMProtocol` (one\nephemeral connection per request, closed when the response arrives), but with a\nsingle request instead of a handshake. Use it only over HTTPS — Basic sends the\ncredentials with every request, merely base64-encoded.\n\n```typescript\nimport { BasicProtocol, SSRS } from '@bleed-believer/ssrs';\n\nconst basic = new BasicProtocol({\n    username: 'administrator',\n    password: 'your-password'\n});\n\nconst ssrs = new SSRS('https://your-server/ReportServer', basic);\n```\n\n### `SSRS`\n\nMain class for interacting with the report server.\n\n```typescript\nconst ssrs = new SSRS(baseUrl: string | URL, protocol: SSRSProtocol);\n```\n\nThe second argument accepts anything implementing `SSRSProtocol`\n(`{ fetch(input, init?): Promise<Response> }`), so you can plug in a custom\ntransport instead of `NTLMProtocol` if your server uses another auth scheme.\n\n#### `ssrs.renderReport(path, format, params?)`\n\nRenders a report and returns a `SSRSReport` object.\n\n| Parameter | Type | Description |\n|-----------|------|-------------|\n| `path` | `string` | Report path on the server (e.g. `'/Reports/MyReport'`) |\n| `format` | `SSRSFormat` | Output format (see below) |\n| `params` | `SSRSReportParams` | Optional report parameters |\n\n`SSRSReportParams` is `Record<string, SSRSReportParamValue | SSRSReportParamValue[] | null>`, where `SSRSReportParamValue` is `string | number | boolean | Date`. Each parameter accepts a single value, an array of values for multi-value parameters (empty arrays are omitted), or `null`:\n\n```typescript\nawait ssrs.renderReport('/Reports/Sales', 'PDF', {\n    region:    ['North', 'South', 'East'],   // multi-value\n    startDate: new Date(2026, 0, 1),         // single value\n    endDate:   null,                         // null parameter\n    active:    true\n});\n```\n\nA `null` value is translated to the SSRS URL Access null syntax\n(`endDate:isnull=true` in the example above). The report parameter must be\ndefined as nullable (*Allow null value*) in the report, otherwise the server\nrejects the render. Multi-value arrays cannot contain `null` members because\nSSRS does not support them.\n\nReturns `Promise<SSRSReport>`:\n\n```typescript\ninterface SSRSReport {\n    mime: string;   // MIME type reported by the server (Content-Type header),\n                    // falling back to the format's default when absent\n    data: Buffer;   // File contents\n}\n```\n\n### `SSRSError`\n\nEvery failed render throws a `SSRSError` (`error.name === 'SSRSError'`):\n\n- **HTTP 401/403** → `Authentication failed: the server returned HTTP <status>`.\n- **HTTP 3xx** → `Unexpected HTTP <status> redirect to <location>`.\n- **Any other non-2xx** → the human-readable message is extracted from the SSRS\n  HTML error page; if the body is not an SSRS error page, the raw text is used.\n\n```typescript\nimport { SSRSError } from '@bleed-believer/ssrs';\n\ntry {\n    await ssrs.renderReport('/Reports/Missing', 'PDF');\n} catch (err) {\n    if (err instanceof SSRSError) {\n        console.error('SSRS rejected the render:', err.message);\n    } else {\n        throw err;\n    }\n}\n```\n\n### `SSRSFormat`\n\nSupported output formats and their fallback MIME types (used when the server\ndoes not send a `Content-Type` header):\n\n| Value | MIME type |\n|-------|-----------|\n| `'PDF'` | `application/pdf` |\n| `'EXCEL'` | `application/vnd.ms-excel` |\n| `'EXCELOPENXML'` | `application/vnd.openxmlformats-officedocument.spreadsheetml.sheet` |\n| `'WORD'` | `application/msword` |\n| `'WORDOPENXML'` | `application/vnd.openxmlformats-officedocument.wordprocessingml.document` |\n| `'PPTX'` | `application/vnd.openxmlformats-officedocument.presentationml.presentation` |\n| `'CSV'` | `text/csv` |\n| `'XML'` | `application/xml` |\n| `'IMAGE'` | `image/tiff` |\n| `'HTML4.0'` | `text/html` |\n| `'HTML5'` | `text/html` |\n| `'MHTML'` | `multipart/related` |\n| `'ATOM'` | `application/atomsvc+xml` |\n| `'RPL'` | `application/octet-stream` |\n| `'NULL'` | `application/octet-stream` |\n","readmeFilename":"README.md","_rev":"1-8cd186bc69581e8615d8619539e67cf8"}