mirror of
https://github.com/hanzoai/chat.git
synced 2026-09-30 20:51:17 +00:00
node:sqlite (DatabaseSync) is a Node 22+ builtin; prod runs Node 20 (Alpine),
so require('node:sqlite') threw ERR_UNKNOWN_BUILTIN_MODULE, cascading through
createModels → applySqliteOverrides → openDatabase and breaking the built dist
("createModels is not a function"). Swap to better-sqlite3-multiple-ciphers
12.11.1 (engines include 20.x, synchronous drop-in, SQLCipher AES-256 at rest —
the Node embodiment of the hanzoai/sqlite contract).
- data-schemas dep + root pnpm.onlyBuiltDependencies allowlist (native addon);
rollup externalizes the driver.
- openDatabase(): lazy require of the driver, identical WAL/synchronous/
busy_timeout/foreign_keys pragmas. Wire the CHAT_SQLITE_KEY encryption seam
(SQLCipher cipher/legacy/key pragmas applied before any page-touching
statement; 64-hex validated, fail-closed; key/path never logged). KMS/CEK
derivation is Milestone 2.
- DocModel: retype db to the driver's Database instance; binding/return parity
already correct (booleans→1/0, dates→ISO, TEXT reads only). engine untouched
(27/27 held).
- parsers: restore the structured-logging-context impl dropped in an upstream
merge (spec #13110 landed without its parsers.ts) — appendRequestContext for
non-debug lines and drop the __SYSTEM__ tenant sentinel from debug traversal.
- models: register the SystemGrant model in createModels (schema/model/methods/
SQLite-spec + coverage guard all existed; only the registration was dangling).
Scrub all node:sqlite/DatabaseSync references from src (comments + spec names).
41 lines
1.1 KiB
JavaScript
41 lines
1.1 KiB
JavaScript
import json from '@rollup/plugin-json';
|
|
import typescript from '@rollup/plugin-typescript';
|
|
import commonjs from '@rollup/plugin-commonjs';
|
|
import nodeResolve from '@rollup/plugin-node-resolve';
|
|
import peerDepsExternal from 'rollup-plugin-peer-deps-external';
|
|
|
|
export default {
|
|
input: 'src/index.ts',
|
|
output: [
|
|
{
|
|
file: 'dist/index.es.js',
|
|
format: 'es',
|
|
sourcemap: true,
|
|
},
|
|
{
|
|
file: 'dist/index.cjs',
|
|
format: 'cjs',
|
|
sourcemap: true,
|
|
},
|
|
],
|
|
plugins: [
|
|
// Allow importing JSON files
|
|
json(),
|
|
// Automatically externalize peer dependencies
|
|
peerDepsExternal(),
|
|
// Resolve modules from node_modules
|
|
nodeResolve(),
|
|
// Convert CommonJS modules to ES6
|
|
commonjs(),
|
|
// Compile TypeScript files and generate type declarations
|
|
typescript({
|
|
tsconfig: './tsconfig.json',
|
|
declaration: true,
|
|
declarationDir: 'dist/types',
|
|
rootDir: 'src',
|
|
}),
|
|
],
|
|
// Do not bundle these external dependencies
|
|
external: ['mongoose', 'better-sqlite3-multiple-ciphers', 'node:crypto'],
|
|
};
|