npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@guardia-technology/sdk

v0.0.10

Published

TypeScript SDK for the Guardia cowork API — typed Result-based HTTP client (ADR-178 thin client).

Readme

@guardia-technology/sdk (TypeScript)

Typed, Result-based HTTP client for the Guardia financial API — the thin client of ADR-178 (rule 6: no domain, no engine), following the bounded-context-template sdks/ pattern. Consumed by the UI (in-container).

Scope. Ships the transport, the injectable auth seam, injected-baseUrl config, the error contract, auth providers, and resource clients whose DTOs derive from the OpenAPI contract. The resource surface is financialSources (create/list/get), financialRecords (push — STREAM_PUSH batch ingest), and documents (batches, files, and pre-signed uploads); further resources (schemas, counterparties) follow the OAS paths.

Base URL (injected)

baseUrl is caller-supplied configuration — the package ships no internal hosts. It resolves: explicit option > $GRD_BASE_API_URL > public default https://api.guardia.technology. What each deployment injects:

| Caller | what to set | | ------ | ----------- | | external / public | nothing — uses the public default | | service-to-service (VPC) | $GRD_BASE_API_URL=https://api.guardia.technology.intra (from the deployment env) | | in-container (SSR/MCP) | $GRD_BASE_API_URL=http://localhost:… |

CallerPosition is kept only as the auth-strategy axis for #752 — it does not resolve the URL.

Usage

import { GuardiaClient } from "@guardia-technology/sdk";

const client = new GuardiaClient({ baseUrl: "https://api.guardia.technology" });
const result = await client.financialSources.list({ pageSize: 20 });
if (result.ok) console.log(result.value.data.length);

Omit baseUrl to use $GRD_BASE_API_URL / the public default. Inject a custom fetchImpl (proxy/retry/test) or an auth provider via the constructor.

Resources

The client exposes one typed subclient per API resource as a lazy, cached accessor. Every method returns Result<DTO, RequestError> and never throws on a documented failure path. State-changing methods take an optional { idempotencyKey } forwarded as the Idempotency-Key header.

| Accessor | Path | Methods | | -------- | ---- | ------- | | client.financialSources | /v1/financial-sources | create, list, get | | client.financialRecords | /financial/v1/financial-records | push | | client.documents | /documents/v1/* | uploadBatch, createBatch, createDocument(s), getBatch, listBatchFiles, getBatchFile + .batches / .files / .storage |

financialRecords.push ingests a batch of 1–500 records and returns PushRecordsAccepted (failedRecordCount). The idempotencyKey is required — the gateway derives each record's event id from it, so a retry is safe (lex-idempotency):

const result = await client.financialRecords.push(
  { records: [{ data: recordIngest }] },
  { idempotencyKey: crypto.randomUUID() },
);
if (result.ok) console.log(result.value.failed_record_count);
import { GuardiaClient } from "@guardia-technology/sdk";

const client = new GuardiaClient({ baseUrl: "https://api.guardia.technology" });

const result = await client.financialSources.get("0199b9f1-3a4b-7c8d-9e0f-1a2b3c4d5e6f");
if (result.ok) {
  console.log(result.value.data.code); // e.g. "corporate-checking-statement-feed"
} else {
  console.error(result.error.code); // e.g. "ERR404_NOT_FOUND"
}

await client.financialSources.create(
  { name: "Corporate Checking", code: "corporate-checking" },
  { idempotencyKey: crypto.randomUUID() },
);

client.documents covers batches, files, and uploads through both a high-level workflow and the thin per-resource surface.

The documents write path sets a User-Agent (server-required) and is server/Node-targeted (the BFF intra position — User-Agent is a forbidden header in the browser Fetch spec). Do not call the write path from a browser.

High-level workflow

uploadBatch runs the full flow — create the batch, then register and upload each file with bounded concurrency (maxConcurrency, default 5). The batch Idempotency-Key is derived from the filenames (a retry collapses onto the same batch), and per-file failures live in the result aggregate rather than a global error (partial-success): the aggregate is err(...) only when batch creation or the inputs themselves fail.

const uploaded = await client.documents.uploadBatch({
  files: [{ filename: "invoice", fileExtension: "pdf", body: bytes }],
  // optional: callbackUrl, metadata, externalEntityId, idempotencyKey, maxConcurrency, userAgent
});
if (uploaded.ok) {
  const { batch, successfulDocuments, failures, isFullySucceeded, isPartiallyFailed } = uploaded.value;
  if (isPartiallyFailed) console.warn(failures.length, "file(s) failed");
}

To register without uploading bytes, create the batch then create the documents (the returned Document carries the pre-signed POST material the caller uploads itself). createBatch requires an explicit idempotencyKey; createDocuments is partial-success like uploadBatch:

const batch = await client.documents.createBatch({
  expectedFilesCount: 2,
  idempotencyKey: crypto.randomUUID(),
});
if (batch.ok) {
  const registered = await client.documents.createDocuments(batch.value.entity_id, {
    files: [
      { filename: "invoice", fileExtension: "pdf" },
      { filename: "statement", fileExtension: "ofx" },
    ],
  });
  // registered.value.successfulDocuments[i].pre_signed_url / .pre_signed_fields
}

Reads — getBatch, getBatchFile, and listBatchFiles (keyset pagination, ADR-0053). Cursors are opaque: feed pagination.next_cursor straight into the next pageToken, and keep pageSize fixed across the walk (changing it mid-walk is a 400):

let pageToken: string | undefined;
do {
  const page = await client.documents.listBatchFiles(batchId, { pageSize: 50, pageToken });
  if (!page.ok) break;
  for (const file of page.value.data) console.log(file.entity_id);
  pageToken = page.value.pagination.next_cursor ?? undefined;
} while (pageToken);

Thin resources

| Accessor | Path | Methods | | -------- | ---- | ------- | | client.documents.batches | /documents/v1/batches | create, get | | client.documents.files | /documents/v1/batches/{id}/files | createInBatch, list, get, update (PATCH) | | client.documents.storage | pre-signed POST target | upload |

files.update is a partial (RFC 7386) update and, like every state-changing call, takes a required idempotencyKey:

await client.documents.files.update(
  batchId,
  fileId,
  { metadata: { reviewed: true } },
  { idempotencyKey: crypto.randomUUID() },
);

Idempotency. uploadBatch derives the batch key from the filenames and each per-file key from (batchId, filename.ext), so a retried upload collapses onto the same batch and documents. Pass an explicit idempotencyKey on any file to override the derived one. createBatch requires the key explicitly (no filenames to derive from).

Types derive from the OpenAPI contract

DTOs and enums are derived from the API contract (components/deployables/api/docs/oas.yaml) via openapi-typescript — not hand-written (ADR-204). The generated module is src/resources/openapi.ts; friendly aliases (FinancialSourceResponse, EntityId, Pagination, …) are re-exported from src/resources/models.ts. Regenerate after a contract change:

npm run generate:types

Develop

npm install
npm run typecheck
npm test
npm run build