Registry / database / fraci
library0.18.0jsnpmunverified

Fractional indexing library for ordered lists with first-class support for Drizzle ORM and Prisma ORM. Version 0.18.0 is the latest stable release, actively maintained with regular updates. Provides string-based (arbitrary base) and binary-based (Uint8Array) fractional indexing, conflict regeneration, and strongly typed TypeScript APIs. Differentiates from other fractional indexing libraries by integrating directly with ORMs and providing robust conflict resolution out of the box.

npm install fraci
INSTALL
IMPORT
SIG · FRACI
F
fraci
databasejavascriptv0.18.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.

fraciString
import { fraciString } from 'fraci'
const { fraciString } = require('fraci')
ESM only; named export for string-based fractional indexing.
fraciBinary
import { fraciBinary } from 'fraci'
import FraciBinary from 'fraci'
ESM only; named export for binary-based fractional indexing using Uint8Array.
defineDrizzleFraci
import { defineDrizzleFraci } from 'fraci/drizzle'
import { defineDrizzleFraci } from 'fraci'
Subpath export for Drizzle integration; not available from main entry.
definePrismaFraci
import { definePrismaFraci } from 'fraci/prisma'
import { definePrismaFraci } from 'fraci'
Subpath export for Prisma integration; not available from main entry.
BASE62
import { BASE62 } from 'fraci'
Predefined base constant for alphanumeric characters.

Demonstrates setting up fractional indexing with Drizzle ORM: define a string-based fraci instance, integrate it into a table schema, and insert a new ordered task with conflict regeneration.

import { BASE62, fraciString, type FractionalIndexOf } from 'fraci'; import { defineDrizzleFraci, drizzleFraci } from 'fraci/drizzle'; const tasksFraci = fraciString({ brand: 'tasks.fi', lengthBase: BASE62, digitBase: BASE62, }); export const tasks = sqliteTable( 'tasks', { id: integer('id').primaryKey({ autoIncrement: true }), title: text('title').notNull(), fi: text('fi').notNull().$type<FractionalIndexOf<typeof tasksFraci>>(), userId: integer('user_id').notNull(), }, (t) => [uniqueIndex('tasks_user_id_fi_idx').on(t.userId, t.fi)], ); export const fiTasks = defineDrizzleFraci( tasksFraci, tasks, tasks.fi, { userId: tasks.userId }, { id: tasks.id }, ); const tfi = drizzleFraci(db, fiTasks); const indices = await tfi.indicesForLast({ userId: 1 }); for (const fi of tfi.generateKeyBetween(...indices)) { try { return await db.insert(tasks).values({ title: 'New Task', fi, userId: 1 }).returning().get(); } catch (error) { if (isIndexConflictError(error)) continue; throw error; } }
Debug
Known issues
gotchaSubpath exports must be explicitly imported: 'fraci/drizzle' or 'fraci/prisma'. Importing from 'fraci' alone will not include ORM integrations.
fix
Use correct import path: import { defineDrizzleFraci } from 'fraci/drizzle'
affects: >=0.18.0
gotchaThe $type helper for FractionalIndexOf requires the fraci instance to be passed as a generic argument, not a string literal. Incorrect usage can lead to type mismatches.
fix
Ensure you use: .$type<FractionalIndexOf<typeof tasksFraci>>()
affects: >=0.18.0
deprecatedCommonJS require() is not supported since the package is ESM-only. Older versions may have had CJS support, but v0.18.0 drops it.
fix
Switch to ESM imports in your project or use dynamic import() if necessary.
affects: >=0.18.0
Errors
Common errors & fixes
Cannot find module 'fraci/drizzle' or its corresponding type declarations.
The import path is incorrect or the package is not installed correctly; subpath exports may not be resolved by some bundlers.
fix
Ensure fraci version 0.18.0 is installed, and your bundler/tsconfig supports subpath exports (requires Node >=16, tsconfig.json with moduleResolution: 'node16' or 'bundler').
Type 'string' is not assignable to type 'FractionalIndexOf<...>'
The column type is not correctly using $type<FractionalIndexOf<...>> from the fraci instance.
fix
Apply .$type<FractionalIndexOf<typeof yourFraciInstance>>() to the column definition.
No overload matches this call... 'defineDrizzleFraci' expects ...
The arguments to defineDrizzleFraci are mismatched: order matters or properties are missing/invalid.
fix
Check the signature: defineDrizzleFraci(fraciInstance, table, fiColumn, groupColumns, cursorColumns). All arguments must be provided.
Upgrade
Version history
0.18.0latest on npm
Audit
Dependencies
drizzle-ormoptionalOptional peer dependency for Drizzle ORM integration
@prisma/clientoptionalOptional peer dependency for Prisma ORM integration
Agent activity
48 hits · last 30 days
node
34
Amazon
1
OpenAI (training)
1
Resources
packagefraci
fraci — npm install fraci · libregistry