@gmresearch/reports-client
v1.7.5
Published
Official TypeScript/JavaScript Client SDK for GMR Reports SaaS Engine
Maintainers
Readme
@gmresearch/reports-client
TypeScript client for the GMR Reports
document rendering API. Renders PDF and XLSX from JasperReports (.jrxml),
Eclipse BIRT and Crystal Reports templates.
Zero dependencies — it uses the runtime's own fetch, so there is nothing to audit
and no transitive surface.
npm install @gmresearch/reports-clientRequires Node 18+ (or any runtime with a global fetch). Ships ES2022 with type
declarations.
Getting a key
Sign up at gmrglobe.com for an API key. The Developer Free tier covers development, testing and evaluation; production use needs a subscription. You can try the API without signing up at sandbox.gmrglobe.com.
Usage
Everything renders through one call. Which report and which format are both arguments, so a new report type does not need a new method and asking for a workbook instead of a PDF is one field.
import { GmrReportsClient } from "@gmresearch/reports-client";
const client = new GmrReportsClient({
apiKey: process.env.GMR_API_KEY!,
baseUrl: "https://api.gmrglobe.com",
});
// A template you supply, with your own data
const pdf = await client.render({
templateSource: jrxml,
templateFormat: "jrxml",
parameters: { title: "Invoice 4021" },
data: [{ item: "Licence", amount: 1200 }],
});Exactly one of type, templateName or templateSource identifies what to
render; naming more than one is rejected rather than silently resolved.
The same report, either format
outputFormat defaults to "pdf":
const xlsx = await client.render({ type: "invoice", outputFormat: "xlsx" });The result is an ArrayBuffer in both cases — write it, stream it, or hand it to
a Blob.
What this deployment offers
const { types } = await client.listReportTypes();
// [{ type: "invoice", title: "Factura", outputFormats: ["pdf", "xlsx"] }, ...]Read it rather than hard-coding a list: a deployment decides its own catalogue.
Other template dialects
templateFormat takes "jasper", "jrxml", "birt" or "crystal". Crystal
means the XML report definition (.rpt.xml), not the binary .rpt — export it
once from Crystal Designer.
Templates stored server-side
await client.uploadExternalTemplate("monthly-statement", jrxml);
const pdf = await client.render({ templateName: "monthly-statement", data: rows });Consumption
const usage = await client.getTenantUsage(tenantId);
// { monthlyUsed: 412, monthlyQuota: 100000, ... }A key reads its own tenant's usage; reading another's needs administrator credentials.
Deprecated
getInvoicePdf, getInvoiceExcel, renderDynamicPdf, renderBirtPdf,
renderCrystalPdf and renderExternalPdf still work and delegate to render().
They encode the report and the format in the method name, which is why adding a
report type used to mean adding methods. Prefer render().
Errors
A non-2xx response throws an Error carrying the status code and the server's
message, so a failure tells you what the API said rather than only that something
went wrong. A 429 means the plan's rate limit or monthly quota is spent — not that
the service is down.
Licence
This client is licensed under the Apache License 2.0 and you may use, modify and redistribute it freely, including in open-source projects.
The GMR Reports rendering engine it talks to is commercial software under its own licence agreement. Installing this client grants you no rights in the engine.
