Registry / database / dobajs

dobajs

JSON →
library0.1.0jsnpmunverified

Doba is a TypeScript schema registry for type-safe data transformations and migrations between different schema variants (e.g., database, frontend, AI contexts). Built on Standard Schema, it supports any Zod, Valibot, or ArkType schemas. Version 0.1.0 is early-stage but functional: O(1) lookup for schemas, graph-based migration path finding, and errors as values. It distinguishes itself from manual transform functions by providing automatic path finding, hops scaling at ~140ns each, and hook support for logging/validation. Release cadence is unknown (pre-1.0).

npm install dobajs
INSTALL
IMPORT
SIG · DOBAJS
D
dobajs
databasejavascriptv0.1.0
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

createRegistry
import { createRegistry } from 'doba'
const { createRegistry } = require('doba')
ESM-only package; requires Node 20+ or bundler with ESM support.
Registry
import type { Registry } from 'doba'
import { Registry } from 'doba'
Registry is exported as a type only. Do not use at runtime.
Schema
import type { Schema } from 'doba'
Type representing an inferrable Standard Schema; useful for parameter annotations.
TransformResult
import type { TransformResult } from 'doba'
Result type from transform(): { ok: boolean, value?: T, error?: StandardSchemaV1Error }

Creates a registry with two schemas and a migration, transforms data from 'db' to 'pub' (stripping secret), and logs the result.

import { createRegistry } from 'doba' import { z } from 'zod' const dbSchema = z.object({ id: z.string(), name: z.string(), secret: z.string() }) const pubSchema = z.object({ id: z.string(), name: z.string() }) const registry = createRegistry({ schemas: { db: dbSchema, pub: pubSchema }, migrations: { 'db->pub': (user) => ({ id: user.id, name: user.name }), }, }) const input = { id: '1', name: 'Alice', secret: 'shh' } const result = await registry.transform(input, 'db', 'pub') if (result.ok) { console.log(result.value) // { id: '1', name: 'Alice' } }
Debug
Known issues
gotchaMigrations must be explicitly registered between every pair you intend to use. Automatic path finding only works if intermediate schemas exist.
fix
Add all required migration edges, or ensure a path exists via intermediate schemas.
affects: >=0.1.0
gotchaThe package ships only ESM. CommonJS require() will fail.
fix
Use dynamic import() or switch to an ESM-compatible project.
affects: >=0.1.0
deprecatedVersion 0.1.0 is pre-release and API may break. Not recommended for production use.
fix
Pin to exact version and test after each upgrade.
affects: >=0.1.0
gotchaThe transform() function is async even if migrations are synchronous. This allows future hook support.
fix
Always await or use .then() on transform calls.
affects: >=0.1.0
Errors
Common errors & fixes
Cannot find module 'doba' or its corresponding type declarations.
Package not installed, or TypeScript cannot resolve ESM exports.
fix
Run 'npm install doba' and ensure 'moduleResolution' is 'bundler' or 'node16' in tsconfig.
SyntaxError: Unexpected token 'export'
Node.js version <20 or CommonJS context does not support ESM syntax.
fix
Upgrade Node to 20+ or use a bundler (esbuild, webpack) with ESM output.
TypeError: registry.transform is not a function
Incorrect import (e.g., imported Registry type instead of createRegistry function).
fix
Use 'import { createRegistry } from 'doba'' and call createRegistry(), then use the returned registry instance.
Error: No migration path from 'schemaA' to 'schemaB'
No direct migration edge or path via intermediate schemas exists.
fix
Register a migration like 'schemaA->schemaB' or ensure intermediate schemas are connected.
Upgrade
Version history
0.1.0latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
11 hits · last 30 days
node
8
Resources
packagedobajs
dobajs — npm install dobajs · libregistry