open-index/open-npm huggingface dataset:
npm package: @raws/es-toolkit
Description: Event sourcing toolkit
Author: Michał Matulka
Latest version: 0.0.2

# Raws event sourcing toolkit

**WARNING**

This library is at very early stage and under heavy development. It does not provide stable API. You shouldn't rely on it yet.

**WARNING 2**

One day after first version was published I've noticed there are downloads. **This toolkit isn't ready yet, for today it's not yet usable and the repository is not yet public, it's published on NPM for testing purposes, please be patient, it will be awesome when it's ready :)**

## Usage

Here be usage

## Interfaces and Base classes

1. `IEvent` interface

   Any object implementing this interface will be accepted as a valid event.

1. `Event` class

   Base class that can be extended to create a valid event. It handles few things for you (such as handling causation and correlation metadata).

1. `CreationEvent` class

   Extend this class to create an event that constructs new Aggregate Root.

1. `AggregateRoot`

   Extend this class to create event sourcing enabled aggregate root that registers and replays events.

1. Coming soon
npm package: @rawsql-ts/adapter-node-pg
Description: Node pg adapter that connects PostgreSQL fixtures to @rawsql-ts/testkit-postgres.
Author: msugiura
Latest version: 0.15.7

# @rawsql-ts/adapter-node-pg

![npm version](https://img.shields.io/npm/v/@rawsql-ts/adapter-node-pg)
![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)

Adapter connecting `pg` (node-postgres) Client/Pool APIs to `@rawsql-ts/testkit-postgres`. All rewriting and fixture logic is delegated to the driver-agnostic package.

## Features

- Drop-in helpers for `pg.Client` and `pg.Pool`
- Named parameter support (`:user_id` compiled to `$1`)
- Reuses fixture validation and schema snapshot from `@rawsql-ts/testkit-postgres`

## Installation

```bash
npm install @rawsql-ts/adapter-node-pg pg
```

`@rawsql-ts/testkit-postgres` is installed automatically as a dependency.

## Quick Start

```ts
import { createPgTestkitClient } from '@rawsql-ts/adapter-node-pg';

const client = createPgTestkitClient({
  connectionFactory: () => pool.connect(),
  tableDefinitions: [
    {
      name: 'users',
      columns: [
        { name: 'id', typeName: 'int', required: true },
        { name: 'email', typeName: 'text', required: true },
      ],
    },
  ],
  tableRows: [
    { tableName: 'users', rows: [{ id: 1, email: 'alice@example.com' }] },
  ],
});

const result = await client.query('SELECT id, email FROM users WHERE id = $1', [1]);
```

## API

| Function | Description |
|----------|-------------|
| `createPgTestkitClient(options)` | Creates a `PgTestkitClient` that lazily opens a `pg` connection and rewrites queries using fixtures. |
| `createPgTestkitPool(connectionString, ...fixtures)` | Builds a `pg.Pool` whose client constructor is replaced with `PgTestkitClient`. |
| `wrapPgClient(client, options)` | Wraps an existing `pg.Client` or `pg.Pool` so queries flow through fixtures without touching your schema. |

All helpers accept the same fixture configuration (`tableDefinitions`, `tableRows`, `ddl`, `missingFixtureStrategy`, etc.) and pass `onExecute` hooks through to `@rawsql-ts/testkit-postgres`.

## License

MIT
npm package: @rawsql-ts/ddl-docs-cli
Description: CLI tool that generates Markdown table definition docs from DDL files using rawsql-ts
Author: msugiura
Latest version: 0.2.6

# @rawsql-ts/ddl-docs-cli

Generate Markdown table definition documents from DDL files.

- DDL is treated as SSOT.
- SQL parsing uses `rawsql-ts`.
- `CREATE TABLE` and `ALTER TABLE ... ADD CONSTRAINT` are applied across the full DDL stream.
- `COMMENT ON TABLE/COLUMN` is parsed via `rawsql-ts`.

## Install

```bash
pnpm --filter @rawsql-ts/ddl-docs-cli build
```

## Usage

```bash
ddl-docs generate --ddl-dir ztd/ddl --out-dir ztd/docs/tables
```

Show help:

```bash
ddl-docs help
ddl-docs help generate
ddl-docs help prune
```

Generated layout:

- `ztd/docs/tables/index.md`
- `ztd/docs/tables/<schema>/index.md`
- `ztd/docs/tables/<schema>/<table>.md`

Options:

- `--ddl-dir <directory>` repeatable recursive directory input
- `--ddl-file <file>` repeatable explicit file input
- `--ddl <file>` alias of `--ddl-file`
- `--ddl-glob <pattern>` repeatable glob pattern input
- `--extensions <csv>` default `.sql`
- `--out-dir <directory>` output root (default `ztd/docs/tables`)
- `--config <path>` optional `ztd.config.json` path
- `--default-schema <name>` schema override for unqualified table names
- `--search-path <csv>` schema search path override
- `--no-index` skip index page generation
- `--strict` fail when warnings exist
- `--column-order <mode>` `definition` (default) or `name`

Prune generated files:

```bash
ddl-docs prune --out-dir ztd/docs/tables
```

Prune preview:

```bash
ddl-docs prune --out-dir ztd/docs/tables --dry-run
```

Optional orphan cleanup:

```bash
ddl-docs prune --out-dir ztd/docs/tables --prune-orphans
```

## VitePress Integration

This tool emits plain Markdown files and index pages.
If you prefer VitePress-side navigation generation, run with `--no-index` and let your site config build navigation from the generated table pages.

## Warnings

Warnings are emitted to `<outDir>/_meta/warnings.json`.
Use `--strict` in CI to treat warnings as failures.

## Memory Notes

Current implementation prioritizes correctness by applying the full DDL stream and aggregating table metadata before rendering.
For large schemas (for example, ~300 tables), follow-up optimization should focus on reducing peak memory by keeping only compact table metadata and discarding statement-level objects early.

## Minimal E2E Sample

See `packages/ddl-docs-cli/examples/minimal-e2e`.
npm package: @rawsql-ts/sql-grep-core
Description: Low-dependency SQL usage analysis engine for rawsql-ts workspaces.
Author: msugiura
Latest version: 0.1.8

# @rawsql-ts/sql-grep-core

![npm version](https://img.shields.io/npm/v/@rawsql-ts/sql-grep-core)
![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)

Low-dependency SQL usage analysis engine extracted from `@rawsql-ts/ztd-cli`.

`@rawsql-ts/sql-grep-core` powers `ztd query uses` and exposes the reusable AST-based schema impact analysis primitives behind that command. It scans SQL catalog specs, resolves their SQL files, parses statements with `rawsql-ts`, and reports table or column usage with deterministic machine-readable output.
It also powers `ztd query match-observed`, which ranks candidate `.sql` assets from observed SELECT text when `queryId` is unavailable.

## What it provides

- Strict-first query target parsing
- SQL catalog spec discovery and lightweight spec loading
- Statement fingerprint generation for stable machine output
- Table and column usage analysis over `rawsql-ts` ASTs
- Observed SQL ranking for source-asset reverse lookup
- Impact and detail report formatting
- Optional span injection for host applications that want telemetry

## Runtime dependencies

- `rawsql-ts`

No CLI framework, watcher, diffing helper, or renderer is required at runtime.

## Typical use case

Use this package when you want the `ztd query uses` engine without taking a dependency on the rest of `ztd-cli`.

```ts
import { buildQueryUsageReport, formatQueryUsageReport } from '@rawsql-ts/sql-grep-core';

const report = buildQueryUsageReport({
  kind: 'table',
  rawTarget: 'public.users',
  rootDir: process.cwd(),
  view: 'impact',
});

console.log(formatQueryUsageReport(report, 'text'));
```

## Relationship to ztd-cli

- `@rawsql-ts/ztd-cli` remains the user-facing CLI surface.
- `ztd query uses` now delegates its analysis engine to `@rawsql-ts/sql-grep-core`.
- Telemetry and command-line UX stay in `ztd-cli`; reusable analysis lives here.

## License

MIT
npm package: @rawsql-ts/sqlite-testkit
Description: SQLite driver adapters for the rawsql-ts select query test harness.
Author: msugiura
Latest version: 0.15.1

﻿# @rawsql-ts/sqlite-testkit

SQLite adapter utilities that let you run repository tests entirely in-memory by shadowing tables with fixture-backed CTEs. The package builds on `@rawsql-ts/testkit-core` for schema validation and SQL rewrites.

## Installation

```bash
npm install @rawsql-ts/sqlite-testkit
```

## `createSqliteSelectTestDriver`

```ts
import Database from 'better-sqlite3';
import { createSqliteSelectTestDriver } from '@rawsql-ts/sqlite-testkit';

const tableSchemas = {
  users: {
    columns: {
      id: 'INTEGER',
      name: 'TEXT',
      role: 'TEXT',
    },
  },
};

const schemaRegistry = {
  getTable(name: string) {
    return tableSchemas[name as keyof typeof tableSchemas];
  },
};

const driver = createSqliteSelectTestDriver({
  connectionFactory: () => new Database(':memory:'),
  fixtures: [
    {
      tableName: 'users',
      rows: [{ id: 1, name: 'Alice', role: 'admin' }],
    },
  ],
  schema: schemaRegistry,
  missingFixtureStrategy: 'error',
});

const rows = await driver.query('SELECT * FROM users');
```

Use `driver.withFixtures([...])` to derive a scoped driver with scenario-specific fixture overrides, and call `driver.close()` to dispose the underlying connection when the suite finishes.

> ℹ️ You can still pass `schema` per fixture for quick experiments, but providing a registry once via the top-level `schema` option keeps large suites maintainable and consistent.

## `wrapSqliteDriver`

Turn any existing `better-sqlite3` connection into a transparent proxy that:

- intercepts `prepare`, `exec`, `all`, `get`, and `run`
- rewrites incoming `SELECT` statements into fixture-backed CTEs (and passes through everything else)
- leaves the underlying repository or DAO code untouched

In other words, you can keep your production query paths as-is and only override read queries during tests.

```ts
import Database from 'better-sqlite3';
import { wrapSqliteDriver } from '@rawsql-ts/sqlite-testkit';

const raw = new Database(':memory:');
const intercepted = wrapSqliteDriver(raw, {
  fixtures: [
    { tableName: 'orders', rows: [{ id: 1 }], schema: { columns: { id: 'INTEGER' } } },
  ],
  missingFixtureStrategy: 'warn',
  recordQueries: true,
  onExecute(sql, params) {
    console.log(`[sql] ${sql}`, params);
  },
});

intercepted.prepare('SELECT * FROM orders').all();

// Inspect the final SQL emitted during the test
console.log(intercepted.queries);
```

Call `intercepted.withFixtures([...])` to create an isolated proxy that applies additional fixtures on top of the base configuration.

## Publishing

Run `npm run release` from `packages/drivers/sqlite-testkit` to execute lint, test, build, `npm pack --dry-run`, and `npm publish --access public`. This mirrors the core package release workflow and lets you publish `@rawsql-ts/sqlite-testkit` directly after bumping the version.
npm package: @rawsql-ts/test-evidence-core
Description: Deterministic PreviewJson to DiffJson transformation for rawsql-ts test evidence.
Author: msugiura
Latest version: 0.2.0

# @rawsql-ts/test-evidence-core

Shared semantic core for test evidence.

## Scope

- Pure model and transform functions only
- No filesystem access
- No markdown rendering

## Schema Versions

- `PREVIEW_SCHEMA_VERSION`: supported major version for `PreviewJson`
- `DIFF_SCHEMA_VERSION`: major version emitted for `DiffJson`

Both are major integers. Unsupported major versions fail with deterministic typed errors.

## Compatibility Policy

- Pre-release (`0.x`): breaking changes are allowed while boundaries are being finalized
- Post-release: breaking schema changes require a major version bump

## Deterministic Error Contract

`DiffCoreErrorCode`:

- `INVALID_INPUT`
- `UNSUPPORTED_SCHEMA_VERSION`

Validation failures are deterministic, including stable error shape fields (`code`, `path`, `schemaVersion`, `details`).

## Pure Intermediate Model

`buildSpecificationModel(previewJson)` returns a pure intermediate model.

- Returns structured data only
- No markdown strings
- No IO
- No side effects

### Function Case Contract

Function test cases in `PreviewJson.testCaseCatalogs[].cases[]` use explicit outcomes:

- `expected: "success" | "throws" | "errorResult"`
- `expected: "throws"` requires `error: { name, message, match }`
- non-throw outcomes require `output`
- optional metadata: `tags: string[]`, `focus: string`
npm package: @rawsql-ts/test-evidence-renderer-md
Description: Markdown projection renderers for rawsql-ts test evidence models.
Author: msugiura
Latest version: 0.3.2

# @rawsql-ts/test-evidence-renderer-md

Markdown projection renderers for test evidence models and diffs.

## Scope

- Markdown output only
- Depends on semantic models from `@rawsql-ts/test-evidence-core`
- Does not compute diffs or normalize semantics

## Projection Rule

Renderer output is a projection. Source of truth remains core models (`SpecificationModel` / `DiffJson`).

## Options Policy

Renderer options are presentation-only.

- Allowed: layout, verbosity, ordering style
- Not allowed: semantic transforms, model normalization, diff computation changes

For specification markdown, `expected: "throws"` cases render `error` blocks and never render `output` blocks.
npm package: @rawsql-ts/testkit-sqlite
Description: SQLite driver adapters for the rawsql-ts select query test harness.
Author: msugiura
Latest version: 1.0.4

# @rawsql-ts/testkit-sqlite

![npm version](https://img.shields.io/npm/v/@rawsql-ts/testkit-sqlite)
![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)

SQLite driver adapter for running repository tests entirely in-memory by shadowing tables with fixture-backed CTEs. Built on `@rawsql-ts/testkit-core` for schema validation and SQL rewrites.

## Features

- In-memory testing with `better-sqlite3`
- Transparent query interception via `wrapSqliteDriver`
- Scenario-specific fixture overrides with `withFixtures`
- Schema registry support for consistent large test suites

## Installation

```bash
npm install @rawsql-ts/testkit-sqlite
```

## Quick Start

```ts
import Database from 'better-sqlite3';
import { createSqliteSelectTestDriver } from '@rawsql-ts/testkit-sqlite';

const driver = createSqliteSelectTestDriver({
  connectionFactory: () => new Database(':memory:'),
  fixtures: [
    {
      tableName: 'users',
      rows: [{ id: 1, name: 'Alice', role: 'admin' }],
      schema: { columns: { id: 'INTEGER', name: 'TEXT', role: 'TEXT' } },
    },
  ],
  missingFixtureStrategy: 'error',
});

const rows = await driver.query('SELECT * FROM users');
```

Use `driver.withFixtures([...])` to derive a scoped driver with scenario-specific overrides, and `driver.close()` to dispose the connection when done.

## Wrapping an Existing Connection

`wrapSqliteDriver` turns any `better-sqlite3` connection into a transparent proxy that intercepts `prepare`, `exec`, `all`, `get`, and `run` — rewriting SELECT statements into fixture-backed CTEs while passing through everything else.

```ts
import Database from 'better-sqlite3';
import { wrapSqliteDriver } from '@rawsql-ts/testkit-sqlite';

const raw = new Database(':memory:');
const intercepted = wrapSqliteDriver(raw, {
  fixtures: [
    { tableName: 'orders', rows: [{ id: 1 }], schema: { columns: { id: 'INTEGER' } } },
  ],
  missingFixtureStrategy: 'warn',
  recordQueries: true,
});

intercepted.prepare('SELECT * FROM orders').all();
console.log(intercepted.queries); // inspect emitted SQL
```

## License

MIT