Scan your whole stack
From OX Research Newsroom
Are you using ts-grm-patches?
Find out what’s in your code.
Scan your apps free in minutes (opens in a new tab)Latest version: v0.4.2
ts-grm-patches was last scanned on 29 Nov 2026 at version 0.4.2. Risk score 0 of 100. No malicious behavior was detected.
| Version | Published | Status |
|---|---|---|
| 0.4.2 LATEST | 29 Nov 2026 | No rules fired |
| 0.4.1 | 27 Nov 2026 | No rules fired |
| 0.4.0 | 27 Nov 2026 | No rules fired |
| 0.3.1 | 26 Nov 2026 | Not shown |
| 0.2.2 | 25 Oct 2026 | Not shown |
Findings for v0.4.2. The score is a capped sum of the weights of the rules that fired — not CVSS, not exploitability, and not a probability. It is not comparable across packages with different scan coverage.
The score describes 0.4.2; other versions have their own rules, not their own score.
The publisher’s own README, as collected from the registry.
English | 简体中文
An optional enhancement layer for ts-grm: dialect-bound clients, fluent query functions, automatic grouping, global filters, and column metadata. Targeted upstream fixes remain part of the package.
The package began with column metadata needed by ts-grm-migrate and now improves query ergonomics and database-function support. ts-grm continues to provide the models, AST, SQL renderer, parameter binding, executor, connection pools and transactions. Enhancements attach through explicit client factories, selected client instances, or the metadata installer.
| Capability | Entry point | Guide |
|---|---|---|
| Database binding at client creation; typed dialect namespace and derived clients | newSqlClient, five dialect subpaths |
Dialect-bound clients |
| In-place fluent expressions + function form of upstream DSL/methods | Native expressions, client.fn, q.fn |
Query functions |
Five-dialect numeric/string implementations, countDistinct, vendor functions and UDF contracts |
Common functions and the matching dialect namespace | Function support |
| Aggregate-aware grouping from full scalar expressions | Opt-in q.autoGroupBy() |
Grouping and limits |
| Cross-model filters with column-based registration | createGlobalFilterManager |
Global filters |
| Column auto-increment/default metadata and BOOL/TEXT query fixes | applyPatches, bool, nullableBool |
Column metadata, query fixes |
Start with the enhancement guide, then choose the features your application needs. The column metadata is consumed by tools such as ts-grm-migrate, which remain responsible for generating the corresponding DDL.
0.4.0 merges fluent methods into native core interfaces and installs them on SPI prototypes. Fields, native DSL results and q.fn share native expressions:
t.amount.times(t.qty).sum().abs().round(2).coalesce(0)
dsl.sum(t.amount).abs().round(2)
t.name.min().trim()
applyPatches(), enhanceClient() and enhanced newSqlClient() install methods
on the loaded core expression prototypes and repairs on all five Driver renderer
prototypes. These installations also affect native clients using the same module
copy; callback/query extensions remain attached to the selected client.
Existing string operations retain their native AST; Driver renderers supply missing
dialect behavior. New portable function nodes resolve the dialect at rendering.
Enhanced clients preserve native select/selectDistinct projections and SqlClient
contracts. See the guide and limitations.
@ts-grm/core and @ts-grm/sql: >=0.0.13 <0.0.15 (verified against
both 0.0.13 and 0.0.14). Upstream implementations are never bundled.0.4.1 (see release notes;
includes a breaking change removing select().where() in favor of native
q.where(...).autoGroupBy().select(...)). 0.3.1 was unpublished due to poor native API
alignment and high per-instance wrapping overhead.pnpm add ts-grm-patches@0.4.1 @ts-grm/core@0.0.14 @ts-grm/sql@0.0.14
For query enhancements, create or enhance a client. applyPatches() is the separate
installer for column modifiers and BOOL/TEXT fixes, and must precede model definitions.
Importing the package alone does not install those runtime patches. Global filters
can also be used with a native client independently.
The application's pool, entityManager and ORDER model are assumed to be defined:
import { PostgresDriver } from '@ts-grm/sql'
import { newSqlClient } from 'ts-grm-patches/postgres'
const db = newSqlClient(new PostgresDriver(pool), { entityManager })
const rows = await db
.createQuery(ORDER, (q, t) =>
q
.where(t.amount.gt(0))
.autoGroupBy()
.select({
category: t.category.lower().trim(),
total: t.amount.sum().abs().round(2).coalesce(0),
count: q.fn.count(),
}),
)
.fetchList()
// db.dialect is 'postgres'; db.fn.postgres is the available vendor namespace.
q.autoGroupBy() acts as a drop-in replacement for native q.groupBy(...), grouping by
the full scalar category expression and excluding aggregate inputs. Each value transform
continues the SQL-function chain. client.fn also builds enhanced base queries and subqueries.
For an existing PostgreSQL client, enhanceClient from ts-grm-patches/postgres
checks the driver and enhances that instance. The root factory can infer a database
from its concrete native driver. Creation, derivation, nested queries and selections
keep the binding; only the matching dialect namespace is exposed.
Common functions include abs/sign/ceil/floor/round/trunc/power/sqrt/exp/ln/log10,
charLength/octetLength and countDistinct. String slicing, search, padding and trim
have dialect implementations. Vendor namespaces cover selected JSON, array,
full-text and date functions, plus an explicit ordinary-function/UDF call contract.
See the catalog and capability gates.
SQLite optional math and octetLength require version/capability declarations. Function semantics, precision, NULL behavior and Unicode handling retain documented vendor boundaries. Upstream aggregate counting is not repaired by this layer. Query enhancement has measurable CPU overhead; see the before/after performance review. SQLite has real execution coverage; the other four families have native-renderer/parameter tests, not server integration coverage.
Some issues in the supported ts-grm version can be worked around from outside. Each workaround first lets upstream try, and steps aside by itself once upstream is fixed — no code changes needed on your side.
| Issue | Status in this package |
|---|---|
#9 prop.bool() columns cannot be used in where / select |
Fixed, also for prop.text() — see BOOL and TEXT columns in queries |
The original metadata additions support ts-grm-migrate: column defaults and auto-increment declarations travel through EntityProp to ColumnDef.prop. Consumers render those declarations into DDL; this installer only supplies the metadata.
import { dsl, model, prop } from '@ts-grm/core'
import { applyPatches } from 'ts-grm-patches'
// Call once before defining any model(...) — idempotent
applyPatches()
const USER = model(
'User',
'id',
class {
id = prop.i32().autoIncrement()
status = prop.str(20).default('active')
createdAt = prop.dt().default(dsl.native.date`now()`)
},
)
Both modifiers return a new instance, mirroring upstream nullable(), and never
mutate the original prop:
// a self-incrementing id: the value comes from the database
const id = prop.i32().autoIncrement()
// a column default: the value used when none is supplied
const status = prop.str(20).default('active')
They can be chained like any other modifier, but the two rarely belong together — a self-incrementing column takes its value from the database, so giving it a literal default is usually not what you want.
default accepts either a literal, constrained by the column's value type, or an
upstream expression node (dsl.native.*, or any ts-grm expression) for calling
SQL functions:
prop.str(20).default('active') // literal
prop.dt().default(dsl.native.date`now()`) // SQL function
prop.str(36).default(dsl.native.str`uuid_generate_v4()`) // SQL function
The patch only carries the expression node; it never renders SQL.
// `columnDef` is the column metadata a consumer receives, e.g. a migration engine
columnDef.prop?.autoIncrement // boolean
columnDef.prop?.default // literal or expression node, or undefined
Both properties are declared on spi.EntityProp through a declaration merge, so they
type-check without a cast. PatchedEntityProp is exported for cases where you need to
name the type explicitly.
isColumnDefaultExpression(value) tells expression nodes apart from literals. It
discriminates on the ts-grm node marker __type().expressionLike rather than
instanceof, so it keeps working when both the ESM and the CJS copy of
@ts-grm/core are loaded in one process.
prop.i32().autoIncrement(). This is
the only option available with @ts-grm/core@0.0.13.ctx.table(...).id("IDENTITY") is reported
as auto-increment.As of
@ts-grm/core@0.0.13the upstream ID-generation strategy is unreleased:IDENTITY/idGenerator/__RootModelContextdo not appear in its type declarations. The development branch does definectx.table(...).id("IDENTITY")(stored onEntity.idGenerator), but the runtime has a single null check as its only consumer, no=== "IDENTITY"branch, and thesqlpackage's DDL layer never reads it — it can be declared but not enforced. The patch therefore leads with the column-level declaration and keeps the branch above purely forward compatible.
Upstream ts-grm ships FilterManager, which registers filters per model. What this
package adds is a way to apply one filter across many models at once —
createGlobalFilterManager(source) returns a native upstream FilterManager that
registers your filters on the target models. Pass it straight to newSqlClient:
import { createGlobalFilterManager } from 'ts-grm-patches'
import type { NumExpression } from '@ts-grm/core'
import { newSqlClient, PostgresDriver } from '@ts-grm/sql'
// an EntityManager is enough — no need to list the models by hand
const globalFilters = await createGlobalFilterManager(entityManager)
// registers only on models that actually have the column
globalFilters.addGlobalFor<NumExpression<number>>('tenantId', (t) => t.eq(currentTenantId))
const client = newSqlClient(new PostgresDriver(pool), {
entityManager,
filterManager: globalFilters,
})
It is async because it takes the models from EntityManager.entities() — upstream's own
enumeration, which already covers the inheritance chain — via the public Entity.model
field. An explicit model array works too.
FilterManager: no wrapping, no private members, no patching. Upstream's
merge() passes an options value through untouched only when its constructor is exactly
FilterManager (or EntityManager) — subclassing it, or passing any other object, gets
shallow-copied and loses its prototype.AND, in registration order: filters added via
add(model, filter) and the global ones interleave exactly as they were registered, so there
is no "global filters first" guarantee.newSqlClient(client, options) derives a client that inherits the manager, because it
travels inside options.undefined
and table.someColumn.eq(...) throws a TypeError that aborts the whole query. Prefer
addGlobalFor(column, build), which skips such models, or guard it yourself with
(table) => table.tenantId?.eq(id).addGlobalFor also filters at lookup time: an entity lacking the column gets an empty
filter list. That matters beyond correctness — upstream decides whether an association may
read the foreign key directly from getFilters(entity).length === 0
(association_resolver.ts), so a non-empty list falls back to a join and can change the
result set for nullable associations. Plain addGlobal() cannot know applicability, so it
makes that list non-empty for every listed model and gives up that optimization.newSqlClient(). A model is registered only if it is listed and no listed ancestor
already applies — upstream collects along the superEntity chain, so a listed ancestor also
covers its descendants, while a column that only exists on the subclass is registered on the
subclass itself. A model that is not listed can still receive a filter through that same
chain.EntityManager.combine(...) yields exactly the parts
you pass (plus their associations), while EntityManager.of(baseDir, paths) enumerates
every model registered in the process — its paths only trigger module loading, so an
of(...) manager covers more than those files.manager.unknownColumns(models) lists column names that no given model has — inherited
columns count as present, matching how applicability is decided — catching typos that would
otherwise make a filter silently never apply.table.__entity exposes the current spi.Entity, so a global filter
can scope itself to — or exclude — specific models.In @ts-grm/core 0.0.13, createTableProp only builds property expressions for numeric,
STR and DATETIME columns, so both prop.bool() and prop.text() throw
ArgumentError: Cannot create table prop … whose scalar type is BOOL/TEXT when used in
where / orderBy / select.
In 0.0.14, upstream fixed runtime BOOL queries (case "BOOL" in
createTableProp) and nullable BOOL NULL decoding (DataRowReader), so this
package's runtime getter automatically steps aside for BOOL on 0.0.14. However,
runtime TEXT queries (createTableProp still lacks case "TEXT") and the
BOOL type-level distribution issue remain unfixed in 0.0.14.
applyPatches() wraps spi.Entity.prototype.tableClass and gives those two kinds a property
expression (BOOL → a comparable expression, TEXT → a full string expression with
like / lower() …). The upstream getter is always called first; the patch only takes
over when it throws that "unsupported scalar type" ArgumentError, so once upstream supports
these columns the patch steps aside by itself. Any other error — including an ArgumentError
for a different reason — is rethrown.
TEXT needs nothing else: prop.text() is already typed as a string column. BOOL also has a
type-level problem — boolean is distributed into true | false, which makes the parameter of
eq resolve to never — so declare query-able boolean columns with bool():
import { applyPatches, bool, nullableBool } from 'ts-grm-patches'
applyPatches()
const ARTICLE = model(
'Article',
'id',
class {
id = prop.i32()
body = prop.text() // queryable after applyPatches()
published = bool().default(false) // instead of prop.bool()
pinned = nullableBool() // instead of prop.bool().nullable()
},
)
client.createQuery(ARTICLE, (q, a) =>
q.where(a.published.eq(true), a.body.like('ts-grm')).select(a.id),
) Find threats in your stack.
OX Radar can check high-priority threats, like critical package CVEs, against your context.
Each incident is marked Detected or Not Detected with a remediation plan and proof all tracked in the Response Center.
The probe returned only these fields for this server — auth requirement, protocol and tool list weren’t observed, so they’re not shown (never guessed).
The publisher’s own links, as the registry reports them. These are not sources for the assessment on this page.