TypeScript finder generator for the data-finder-ts runtime library
Project description
data-finder-ts
TypeScript port of data-finder, a model-driven SQL query builder with temporal (milestoned) data support. A Python generator reads the same mapping definitions used by the Python project and emits strongly-typed TypeScript finder classes.
What it does
You define a mapping between your domain model and relational tables (in Python or Markdown). The generator produces a typed *Finder class per entity. You use those classes to build and run SQL queries without writing SQL directly:
const tf = new TradeFinder();
// Filter, join, milestoning applied automatically
const rows = await tf.findAll(
null, // business date (null = not applicable)
new Date(), // processing valid-at (temporal snapshot)
[tf.symbol(), tf.price(), tf.account().name()],
tf.symbol().eq('AAPL'),
).toRows();
Temporal filtering (in_z <= ? AND out_z > ?) is injected automatically based on the milestoning type declared in the mapping.
Setup
npm install
# Install Python generator dependencies (system-wide, no virtualenv)
pip3 install jinja2 markdown-it-py
Node ≥ 20 required.
Generating finders
Generated files are gitignored — regenerate them before running tests on a fresh clone.
# From programmatic mapping definitions (example/mappings.py)
python3 example/generate.py # → example/generated/
# From a markdown mapping file (finance_mapping.md in sibling data-finder repo)
python3 example/generate_from_markdown.py # → tests/generated_markdown/
The generators import directly from the sibling ../data-finder Python project, which must be present.
Running tests
npm test # all tests
npx vitest run tests/duckdb.test.ts # single file
npm run build # type-check only
Tests use an in-memory DuckDB instance via @duckdb/node-api. tests/duckdb.test.ts loads CSV fixtures from example/data/; tests/duckdb-markdown.test.ts seeds data with INSERT statements.
Milestoning types
| Type | Mapping class | findAll args used |
|---|---|---|
| None | — | neither |
| Processing temporal | ProcessingDateMilestonesPropertyMapping |
processingValidAt |
| Single business date | SingleBusinessDateMilestonePropertyMapping |
businessDate |
| Business date + processing | BusinessDateAndProcessingMilestonePropertyMapping |
both |
| Bi-temporal | BiTemporalMilestonePropertyMapping |
both |
Defining a mapping (Markdown)
## Model: my_model.md
## DataStore: my_db (Database)
| Scheme | processing_start | processing_end |
|------------------|------------------|----------------|
| processing_only | in_z | out_z |
### Schema: trading
#### Table: trades → Trade (milestoning: processing_only)
| Column | Type | Key | Property |
|------------|-----------|-----|----------|
| sym | VARCHAR | | symbol |
| price | DOUBLE | | price |
| account_id | INT | FK | account |
| in_z | TIMESTAMP | | valid_from |
| out_z | TIMESTAMP | | valid_to |
#### Association: TradeAccount
| Source Column | Target Table | Target Column |
|---------------|----------------|---------------|
| account_id | account_master | ID |
Load and generate:
from mapping_markdown.markdown_mapping import load
from ts_generator.generator import generate
mapping = load('my_mapping.md')
generate(mapping, 'output/')
Reverse associations
When a model association is declared (e.g. Trade → Account), the generator adds a trades() method on AccountFinder pointing back to TradeRelatedFinder. Because ESM circular imports can't be resolved with static import, finders self-register at module load via registerRelatedFinderClass. When using a reverse association in tests, import the source finder's module first:
await import('./generated/TradeFinder'); // ensures TradeRelatedFinder is registered
const { AccountFinder } = await import('./generated/AccountFinder');
const af = new AccountFinder();
const rows = await af.findAll(null, null, [af.name(), af.trades().symbol()]).toRows();
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file data_finder_ts_generator-0.1.2.tar.gz.
File metadata
- Download URL: data_finder_ts_generator-0.1.2.tar.gz
- Upload date:
- Size: 75.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d11f5207a021ba4c690c6a75e4d8a93d3d4774ffe7be4ba0702fba4eaebb0519
|
|
| MD5 |
97e18be6adb8d7421804ea97333ed6d1
|
|
| BLAKE2b-256 |
d68150ceca8439b44cee7622b2019fef94613c617871440e838baac048af4fae
|
Provenance
The following attestation bundles were made for data_finder_ts_generator-0.1.2.tar.gz:
Publisher:
release.yml on jackie-h/data-finder-ts
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
data_finder_ts_generator-0.1.2.tar.gz -
Subject digest:
d11f5207a021ba4c690c6a75e4d8a93d3d4774ffe7be4ba0702fba4eaebb0519 - Sigstore transparency entry: 1810481446
- Sigstore integration time:
-
Permalink:
jackie-h/data-finder-ts@149e5987d6a42357c5a3fda1a582ba15e049a19e -
Branch / Tag:
refs/tags/v0.1.2 - Owner: https://github.com/jackie-h
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@149e5987d6a42357c5a3fda1a582ba15e049a19e -
Trigger Event:
release
-
Statement type:
File details
Details for the file data_finder_ts_generator-0.1.2-py3-none-any.whl.
File metadata
- Download URL: data_finder_ts_generator-0.1.2-py3-none-any.whl
- Upload date:
- Size: 12.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d7b1e3e7d81790cc598821bf05ce7f8b04e08d511da79935a02bdc9c29bd4f9b
|
|
| MD5 |
db1a15679d807125874b3eda7b5a25f5
|
|
| BLAKE2b-256 |
439b3e69bb62423e27ba249ec0f0551f139d5a4571afe8ebf9791e5ec6a63334
|
Provenance
The following attestation bundles were made for data_finder_ts_generator-0.1.2-py3-none-any.whl:
Publisher:
release.yml on jackie-h/data-finder-ts
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
data_finder_ts_generator-0.1.2-py3-none-any.whl -
Subject digest:
d7b1e3e7d81790cc598821bf05ce7f8b04e08d511da79935a02bdc9c29bd4f9b - Sigstore transparency entry: 1810481516
- Sigstore integration time:
-
Permalink:
jackie-h/data-finder-ts@149e5987d6a42357c5a3fda1a582ba15e049a19e -
Branch / Tag:
refs/tags/v0.1.2 - Owner: https://github.com/jackie-h
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@149e5987d6a42357c5a3fda1a582ba15e049a19e -
Trigger Event:
release
-
Statement type: