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

jsonapi-rsql-interface-pg

v1.0.0

Published

PostgreSQL execution adapter for jsonapi-rsql-interface query plans.

Readme

jsonapi-rsql-interface-pg

jsonapi-rsql-interface-pg is a deterministic PostgreSQL execution adapter for plans produced by jsonapi-rsql-interface.

Core scope:

  • compile-only adapter surfaces:
    • compileWhere(plan, mapping)
    • compileOrderBy(plan, mapping)
    • compileLimitOffset(plan, mapping)
    • compileSecurityPredicate(plan, mapping, securityContext)
    • compileSelect(plan, mapping) (root-table projection only in v1.2.x)
  • optional convenience helper:
    • assembleSelectSql(...) (assembly-only, no new semantics)

Utilities:

  • prepareMapping(mapping)
  • ensurePreparedMapping(mapping)
  • getTableSql(mapping)
  • ADAPTER_DIALECT_PROFILE (postgresql-v1-core)

Non-goals in v1.2.x:

  • no policy expansion
  • no implicit feature fallbacks
  • no SQL execution
  • no include/join SQL planning

Mapping contract (baseline)

{
  dialect_profile: "postgresql-v1-core",
  version: "map.v1",
  hash: "sha256:...",
  resource: {
    table: "users",   // ASCII identifier tokens only
    type: "users"
  },
  fields: {
    id: { kind: "column", column: "id" },
    status: { kind: "column", column: "status" },
    name_lc: {
      kind: "expression",
      trusted: true,
      sql: "lower(name)",
      expression_id: "name_lower"
    }
  },
  default_select: ["id", "status"],
  limits: {
    max_predicates: 200,
    max_selected_columns: 100,
    max_order_by_keys: 25,
    max_fragment_count: 8,
    max_fragment_text_length: 100000,
    max_fragment_values: 10000,
    max_sql_text_length: 250000,
    max_bound_values: 50000
  }
}

Notes:

  • dialect profile is pinned by adapter version. Any unsupported profile is rejected with pg_feature_not_supported.
  • expression mappings require explicit trusted: true.
  • operator-to-SQL mapping is closed in adapter code.
  • mapping cannot provide SQL operator templates.

Security predicate input

compileSecurityPredicate(plan, mapping, securityContext) requires a runtime security context value for plan.security.predicate.bound_parameter_key.

Accepted lookup forms:

  • securityContext[bindingKey]
  • securityContext.values[bindingKey]

Missing value fails deterministically with pg_security_predicate_required.

Assembly helper contract

assembleSelectSql(...) accepts only structured fragments:

{
  table: "\"users\"",
  select: { text: "\"id\" AS \"id\"", values: [] },
  where: { text: "(\"status\" = $1)", values: ["active"] },
  security: { text: "(\"tenant_id\" = $1)", values: ["tenant-a"] },
  orderBy: { text: "ORDER BY \"id\" DESC", values: [] },
  limitOffset: { text: "LIMIT $1 OFFSET $2", values: [25, 0] }
}

Behavior:

  • table must be the exact value from getTableSql(mapping) (mapping-derived only)
  • strict fragment-shape validation
  • deterministic placeholder renumbering to contiguous $1..$n
  • deterministic left-to-right value ordering
  • no semantic inference, defaults, or SQL execution

Error model

Stable adapter error code namespace:

  • pg_invalid_plan_shape
  • pg_invalid_mapping_shape
  • pg_mapping_missing
  • pg_operator_not_supported
  • pg_feature_not_supported
  • pg_security_predicate_required
  • pg_fragment_invalid
  • pg_limits_exceeded

Authoritative constraints:

  • docs/ADAPTER_PG_SECURITY_PERFORMANCE_CONSTRAINTS.md (repo root)