Registry / database / apiagex-database

apiagex-database

JSON →
library0.6.1jsnpmunverified

Apiagex Database is the database adapter contract package for the Apiagex headless CMS, currently at version 0.6.1. It provides placeholder adapters for SQLite, PostgreSQL, and MySQL, along with a selector function that chooses the correct adapter based on configuration. Designed for use within Apiagex projects, it uses Kysely under the hood and stores role metadata with roleKind, admin permissions in admin_permissions, content API permissions in permissions, hashed API tokens in api_tokens, and webhook data in webhooks, webhook_events, and webhook_deliveries. It is still in MVP stage, with evolving schemas and adapter implementations.

npm install apiagex-database
INSTALL
IMPORT
SIG · APIAGEX-DATABASE
A
apiagex-database
databasejavascriptv0.6.1
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.

selectDatabaseAdapter
import { selectDatabaseAdapter } from 'apiagex-database'
const { selectDatabaseAdapter } = require('apiagex-database')
Package is ESM-only. CommonJS require is not supported.
SqliteAdapterPlaceholder
import { SqliteAdapterPlaceholder } from 'apiagex-database/adapters/sqlite'
import { SqliteAdapterPlaceholder } from 'apiagex-database'
Adapters are exported from subpaths, not the main entry point.
PostgresAdapterPlaceholder
import { PostgresAdapterPlaceholder } from 'apiagex-database/adapters/postgres'
import { PostgresAdapterPlaceholder } from 'apiagex-database/adapters/pg'
Use 'postgres' subpath, not 'pg'.
MysqlAdapterPlaceholder
import { MysqlAdapterPlaceholder } from 'apiagex-database/adapters/mysql'
import { MysqlAdapterPlaceholder } from 'apiagex-database'
Must import from the adapter subpath.

Shows how to import and use selectDatabaseAdapter to create a SQLite database adapter and run a query.

import { selectDatabaseAdapter } from 'apiagex-database'; const adapter = selectDatabaseAdapter({ client: 'sqlite', file: './data/apiagex.db', }); // Use adapter to run queries via Kysely const db = adapter.getDb(); const users = await db.selectFrom('users').selectAll().execute(); console.log(users);
Debug
Known issues
breakingRole metadata schema changed: roleKind field added. Admin roles are owner, admin, schema-manager, and user-manager; API roles are separate.
fix
Update database schema to include roleKind column and migrate existing role data accordingly.
affects: <0.6.0
breakingPermissions tables restructured: admin permissions moved to admin_permissions table, content API permissions remain in permissions table.
fix
Migrate admin permissions from permissions to admin_permissions table before upgrading.
affects: <0.5.0
breakingAPI tokens are now stored hashed in api_tokens table instead of plaintext.
fix
Rehash all existing API tokens and store in api_tokens table.
affects: <0.4.0
gotchaPackage is ESM-only. Using require() will fail with Module not found.
fix
Use import syntax and ensure project is configured for ESM ("type": "module" in package.json).
affects: >=0.1.0
gotchaAdapter placeholders are not fully implemented; they return mock data.
fix
Use only for prototyping. For production, implement real adapters or use a different database layer.
affects: >=0.1.0
Errors
Common errors & fixes
Cannot find module 'apiagex-database' or its corresponding type declarations.
Package is not installed or TypeScript types are not resolved.
fix
Run 'npm install apiagex-database' and ensure tsconfig.json includes node_modules in typeRoots or uses 'moduleResolution': 'node'.
ERR_MODULE_NOT_FOUND: Cannot find package 'kysely' imported from 'apiagex-database'
Peer dependency kysely is missing.
fix
Install kysely as a dependency: 'npm install kysely'.
TypeError: selectDatabaseAdapter is not a function
CommonJS require was used instead of ESM import.
fix
Use 'import { selectDatabaseAdapter } from 'apiagex-database'' instead of require.
Upgrade
Version history
0.6.1latest on npm
Audit
Dependencies
kyselyrequiredKysely is used as the SQL query builder and database adapter interface
Agent activity
16 hits · last 30 days
node
14
OpenAI (training)
1
Resources
apiagex-database — npm install apiagex-database · libregistry