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

@zhongmiao/meta-lc-datasource

v0.2.0

Published

English | [中文文档](./README_zh.md)

Readme

@zhongmiao/meta-lc-datasource

English | 中文文档

Package Role

datasource owns stable physical data execution contracts at the package root. Concrete Postgres adapters are exposed through the explicit secondary entry @zhongmiao/meta-lc-datasource/postgres.

Responsibilities

  • Define datasource and DB configuration types.
  • Expose Postgres clients from the /postgres secondary entry.
  • Execute compiled SQL through the adapter boundary and normalize rows, row counts, metadata, and errors.

Relationship With Other Packages

  • Upstream: runtime.
  • Downstream: business_db; datasource has no workspace package dependencies.
  • runtime consumes datasource adapters through the stable root execution contract.
  • Composition roots wire concrete Postgres adapters through @zhongmiao/meta-lc-datasource/postgres; BFF does not depend on this package.
  • query produces SQL that a datasource adapter can execute.
  • permission affects the constraints included before execution.
  • kernel remains separate; metadata versioning is not owned by this package.
  • PostgresOrgScopeAdapter is a platform data-scope adapter used by runtime permission context assembly.
  • Orders-specific demo mutation logic lives in examples/orders-demo only.
  • Core datasource only keeps generic Postgres execution and platform adapter edges such as org-scope loading.
  • Package root exports contracts only; Postgres implementation is not exposed from root.

Minimal Flow

flowchart LR
  Config["DbConfig"] --> Adapter["PostgresDatasourceAdapter"]
  Request["DatasourceExecutionRequest<br/>SQL + params"] --> Adapter
  Adapter --> BusinessDb[("business_db")]
  BusinessDb --> Result["rows / rowCount / metadata"]

Commands

pnpm --filter @zhongmiao/meta-lc-datasource build
pnpm --filter @zhongmiao/meta-lc-datasource test

Postgres Secondary Entry

The package root is contract-only and does not force Postgres driver installation. Consumers that import @zhongmiao/meta-lc-datasource/postgres must install a compatible pg version in their composition root.

import {
  PostgresDatasourceAdapterFactory,
  createPostgresDatasourceAdapter
} from "@zhongmiao/meta-lc-datasource/postgres";

const adapter = createPostgresDatasourceAdapter(config);
const adapterFromClassFactory = new PostgresDatasourceAdapterFactory().create(config);

Factory-first rule: composition roots should use createPostgresDatasourceAdapter or PostgresDatasourceAdapterFactory. PostgresDatasourceAdapter remains exported as an advanced API for low-level integration and package-local tests, but application wiring must not directly new PostgresDatasourceAdapter().

Boundary Notes

  • Keep adapter code focused on database execution and lifecycle.
  • Import Postgres implementation from @zhongmiao/meta-lc-datasource/postgres, not the package root.
  • Do not deep import src/postgres/* from application code.
  • Receives compiled request / SQL command.
  • Must not compile Query AST.
  • Must not depend on query / permission / runtime.
  • Business demo adapters must live under examples/*, not in this package.
  • Keep platform adapters generic; business semantics must not become implicit datasource orchestration.
  • Do not add HTTP controller or runtime orchestration here.
  • Do not read BFF-specific request objects here.