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

@doccop/core

v0.2.0

Published

Core engine for doccop document generation — docx parsing, SDT placeholder manipulation, variable resolution, requisites injection

Downloads

777

Readme

@doccop/core

The pure engine of doccop.docx parsing, SDT-based placeholder manipulation, two-phase render with variable substitution, and per-subtype "requisites" block injection. No I/O. No HTTP. No database. Just functions over a DocxArchive.

Status: 0.2.0-beta.0 — feature-frozen for the 0.2.0 line; behavioural fixes only until stable.

Install

npm install @doccop/core

Runtime deps: pizzip (MIT) + @xmldom/xmldom (MIT). Both vendored licenses are MIT or MIT-compatible.

Minimal example

import fs from "node:fs";
import { parse, render } from "@doccop/core";
import type { EntityResolver, RenderConfig, RenderRequest } from "@doccop/core";

const archive = parse(fs.readFileSync("contract-template.docx"));

const partyA: EntityResolver = {
  scope: "party_a",
  async resolve(key) {
    if (key === "full_name") return { kind: "text", value: "ACME Ltd" };
    return { kind: "absent", reason: `unknown key ${key}` };
  },
};

const request: RenderRequest = {
  userId: "user-1",
  templateId: "t-1",
  templateVersionId: "tv-1",
  templateCategory: null,
  documentNumber: "001/2026",
  parties: [{ role: "party_a", entityType: "organization", entityId: "acme" }],
  now: new Date(),
};

const config: RenderConfig = { resolvers: [partyA] };

const result = await render(archive, request, config);
fs.writeFileSync("contract.docx", result.docx);

What this package exposes

| Subsystem | Functions | |---|---| | docx | parse, serialize, ensureParaIds, listParagraphs, findByParaId | | placeholders | list, wrap, wrapBlock, unwrap, replace, decomposeTag, validateAlias | | preview | preview (returns { html, anchors } for in-browser editors) | | render | render (the substitution pipeline), validateValue | | requisites | injectRequisites, resolveAndInject, serializeArchive |

All types (EntityResolver, RequisitesResolver, StorageAdapter, Placeholder, DocCopConfig, etc.) are exported. The 19 DocCopError subclasses are the engine's exception surface — branch on error.code for HTTP / i18n mapping.

When to reach for the server / storage packages

  • Wrap the engine in an HTTP API with auth + idempotency + rate-limit → @doccop/server (Fastify plugin).
  • Persist templates / snippets / documents in Postgres via Drizzle → @doccop/storage-postgres (reference store implementations + filesystem blob storage).

Documentation

  • Quickstart — install → first rendered document in under ten minutes.
  • Integration guide — adapter-by-adapter walkthrough (storage, resolvers, auth, stores).
  • Architecture — internal design, two-phase render, requisites pipeline.
  • demo-app — runnable end-to-end Fastify + in-memory stores example.

Compatibility

  • Node ≥ 20 (uses node:fs/promises, ESM, URL).
  • ESM only. CommonJS hosts: use dynamic import().
  • TypeScript: strict mode supported, including noUncheckedIndexedAccess and exactOptionalPropertyTypes.

License

MIT — see LICENSE.