hazo_connect 3.10.0 → 4.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGE_LOG.md +112 -0
- package/README.md +21 -0
- package/dist/adapters/base-adapter.js +22 -24
- package/dist/adapters/base-adapter.js.map +1 -1
- package/dist/adapters/better-sqlite3-adapter.d.ts.map +1 -1
- package/dist/adapters/better-sqlite3-adapter.js +58 -82
- package/dist/adapters/better-sqlite3-adapter.js.map +1 -1
- package/dist/adapters/clause-builder.js +24 -36
- package/dist/adapters/clause-builder.js.map +1 -1
- package/dist/adapters/file-adapter.js +6 -10
- package/dist/adapters/file-adapter.js.map +1 -1
- package/dist/adapters/pg-adapter.js +16 -22
- package/dist/adapters/pg-adapter.js.map +1 -1
- package/dist/adapters/postgrest-adapter.js +31 -33
- package/dist/adapters/postgrest-adapter.js.map +1 -1
- package/dist/adapters/sqlite-adapter.js +71 -70
- package/dist/adapters/sqlite-adapter.js.map +1 -1
- package/dist/adapters/supabase-adapter.js +20 -23
- package/dist/adapters/supabase-adapter.js.map +1 -1
- package/dist/connect-config.js +39 -43
- package/dist/connect-config.js.map +1 -1
- package/dist/crypto/field-crypto.js +8 -14
- package/dist/crypto/field-crypto.js.map +1 -1
- package/dist/default-logger.js +10 -16
- package/dist/default-logger.js.map +1 -1
- package/dist/factory.js +24 -30
- package/dist/factory.js.map +1 -1
- package/dist/helpers.js +9 -15
- package/dist/helpers.js.map +1 -1
- package/dist/index.js +1 -2
- package/dist/index.js.map +1 -1
- package/dist/log-level-wrapper.d.ts +1 -1
- package/dist/log-level-wrapper.d.ts.map +1 -1
- package/dist/log-level-wrapper.js +2 -6
- package/dist/log-level-wrapper.js.map +1 -1
- package/dist/migrations/runner.js +13 -19
- package/dist/migrations/runner.js.map +1 -1
- package/dist/nextjs/api-route-helpers.d.ts.map +1 -1
- package/dist/nextjs/api-route-helpers.js +10 -21
- package/dist/nextjs/api-route-helpers.js.map +1 -1
- package/dist/nextjs/index.d.ts.map +1 -1
- package/dist/nextjs/index.js +4 -34
- package/dist/nextjs/index.js.map +1 -1
- package/dist/nextjs/route-setup.js +32 -39
- package/dist/nextjs/route-setup.js.map +1 -1
- package/dist/nextjs/server-only.d.ts.map +1 -1
- package/dist/nextjs/server-only.js +3 -26
- package/dist/nextjs/server-only.js.map +1 -1
- package/dist/nextjs/setup-helpers.d.ts.map +1 -1
- package/dist/nextjs/setup-helpers.js +20 -36
- package/dist/nextjs/setup-helpers.js.map +1 -1
- package/dist/providers/index.js +2 -12
- package/dist/providers/index.js.map +1 -1
- package/dist/providers/neo4j-provider.js +15 -54
- package/dist/providers/neo4j-provider.js.map +1 -1
- package/dist/providers/redis-provider.js +13 -51
- package/dist/providers/redis-provider.js.map +1 -1
- package/dist/query-builder.d.ts +1 -1
- package/dist/query-builder.d.ts.map +1 -1
- package/dist/query-builder.js +33 -34
- package/dist/query-builder.js.map +1 -1
- package/dist/server/index.d.ts +14 -2
- package/dist/server/index.d.ts.map +1 -1
- package/dist/server/index.js +35 -73
- package/dist/server/index.js.map +1 -1
- package/dist/sqlite/admin-service.d.ts +3 -3
- package/dist/sqlite/admin-service.d.ts.map +1 -1
- package/dist/sqlite/admin-service.js +44 -53
- package/dist/sqlite/admin-service.js.map +1 -1
- package/dist/sqlite/placeholder-rewrite.js +5 -9
- package/dist/sqlite/placeholder-rewrite.js.map +1 -1
- package/dist/sqlite/query-translator.d.ts +1 -1
- package/dist/sqlite/query-translator.d.ts.map +1 -1
- package/dist/sqlite/query-translator.js +14 -22
- package/dist/sqlite/query-translator.js.map +1 -1
- package/dist/testing/index.js +1 -7
- package/dist/testing/index.js.map +1 -1
- package/dist/types.js +3 -6
- package/dist/types.js.map +1 -1
- package/dist/ui/components/sqlite-admin-client.js +48 -51
- package/dist/ui/components/sqlite-admin-client.js.map +1 -1
- package/dist/ui/index.js +2 -10
- package/dist/ui/index.js.map +1 -1
- package/dist/utils/assertions.js +8 -12
- package/dist/utils/assertions.js.map +1 -1
- package/dist/utils/config-validator.js +2 -6
- package/dist/utils/config-validator.js.map +1 -1
- package/dist/utils/database-url.js +4 -10
- package/dist/utils/database-url.js.map +1 -1
- package/dist/utils/jsonb.js +1 -4
- package/dist/utils/jsonb.js.map +1 -1
- package/dist/utils/result.js +3 -8
- package/dist/utils/result.js.map +1 -1
- package/dist/utils/sqlite-utils.js +10 -18
- package/dist/utils/sqlite-utils.js.map +1 -1
- package/dist/utils/wasm-resolver.d.ts.map +1 -1
- package/dist/utils/wasm-resolver.js +58 -57
- package/dist/utils/wasm-resolver.js.map +1 -1
- package/dist/utils/where-builder.d.ts +1 -1
- package/dist/utils/where-builder.d.ts.map +1 -1
- package/dist/utils/where-builder.js +14 -19
- package/dist/utils/where-builder.js.map +1 -1
- package/docs/migration-guide.md +36 -0
- package/docs/troubleshooting.md +42 -0
- package/package.json +18 -25
- package/scripts/{postinstall-setup.js → postinstall-setup.cjs} +1 -1
- /package/scripts/{setup-routes.js → setup-routes.cjs} +0 -0
package/dist/utils/result.js
CHANGED
|
@@ -1,21 +1,16 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
/**
|
|
3
2
|
* Purpose: Discriminated union result type for database operations
|
|
4
3
|
*
|
|
5
4
|
* Provides a consistent error-handling pattern without try/catch boilerplate.
|
|
6
5
|
* Integrates with HazoConnectError-shaped objects to extract status codes.
|
|
7
6
|
*/
|
|
8
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
-
exports.wrapResult = wrapResult;
|
|
10
|
-
exports.ok = ok;
|
|
11
|
-
exports.err = err;
|
|
12
7
|
/**
|
|
13
8
|
* Wrap an async operation in a DbResult, catching errors automatically.
|
|
14
9
|
* @param fn - Async function to execute
|
|
15
10
|
* @param default_status - Default HTTP status on error (default: 500)
|
|
16
11
|
* @returns DbResult with data or error
|
|
17
12
|
*/
|
|
18
|
-
async function wrapResult(fn, default_status = 500) {
|
|
13
|
+
export async function wrapResult(fn, default_status = 500) {
|
|
19
14
|
try {
|
|
20
15
|
const data = await fn();
|
|
21
16
|
return { ok: true, data };
|
|
@@ -31,13 +26,13 @@ async function wrapResult(fn, default_status = 500) {
|
|
|
31
26
|
/**
|
|
32
27
|
* Create a successful DbResult.
|
|
33
28
|
*/
|
|
34
|
-
function ok(data) {
|
|
29
|
+
export function ok(data) {
|
|
35
30
|
return { ok: true, data };
|
|
36
31
|
}
|
|
37
32
|
/**
|
|
38
33
|
* Create a failed DbResult.
|
|
39
34
|
*/
|
|
40
|
-
function err(message, status = 500, code) {
|
|
35
|
+
export function err(message, status = 500, code) {
|
|
41
36
|
return { ok: false, error: { message, code }, status };
|
|
42
37
|
}
|
|
43
38
|
//# sourceMappingURL=result.js.map
|
package/dist/utils/result.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"result.js","sourceRoot":"","sources":["../../src/lib/utils/result.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"result.js","sourceRoot":"","sources":["../../src/lib/utils/result.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AASH;;;;;GAKG;AACH,MAAM,CAAC,KAAK,UAAU,UAAU,CAC9B,EAAoB,EACpB,cAAc,GAAG,GAAG;IAEpB,IAAI,CAAC;QACH,MAAM,IAAI,GAAG,MAAM,EAAE,EAAE,CAAA;QACvB,OAAO,EAAE,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,CAAA;IAC3B,CAAC;IAAC,OAAO,CAAU,EAAE,CAAC;QACpB,MAAM,SAAS,GAAG,CAAwC,CAAA;QAC1D,MAAM,OAAO,GAAI,SAAS,EAAE,OAAkB,IAAI,eAAe,CAAA;QACjE,MAAM,IAAI,GAAG,SAAS,EAAE,IAA0B,CAAA;QAClD,MAAM,MAAM,GAAI,SAAS,EAAE,UAAqB,IAAI,cAAc,CAAA;QAClE,OAAO,EAAE,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,EAAE,MAAM,EAAE,CAAA;IACxD,CAAC;AACH,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,EAAE,CAAI,IAAO;IAC3B,OAAO,EAAE,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,CAAA;AAC3B,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,GAAG,CAAY,OAAe,EAAE,MAAM,GAAG,GAAG,EAAE,IAAa;IACzE,OAAO,EAAE,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,EAAE,MAAM,EAAE,CAAA;AACxD,CAAC"}
|
|
@@ -1,18 +1,10 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
/**
|
|
3
2
|
* Purpose: Shared SQLite utility functions used across adapters, query translators, and admin services.
|
|
4
3
|
*
|
|
5
4
|
* This module provides common utilities for SQLite operations including identifier quoting,
|
|
6
5
|
* value normalization, and validation functions.
|
|
7
6
|
*/
|
|
8
|
-
|
|
9
|
-
exports.quoteIdentifier = quoteIdentifier;
|
|
10
|
-
exports.normalizeValue = normalizeValue;
|
|
11
|
-
exports.isPlainObject = isPlainObject;
|
|
12
|
-
exports.sanitizeTableName = sanitizeTableName;
|
|
13
|
-
exports.validateIdentifier = validateIdentifier;
|
|
14
|
-
exports.getIdentifierPattern = getIdentifierPattern;
|
|
15
|
-
const hazo_core_1 = require("hazo_core");
|
|
7
|
+
import { HazoValidationError } from 'hazo_core';
|
|
16
8
|
const identifierPattern = /^[A-Za-z_][A-Za-z0-9_]*$/;
|
|
17
9
|
/**
|
|
18
10
|
* Quote a SQLite identifier (table name, column name, etc.)
|
|
@@ -20,14 +12,14 @@ const identifierPattern = /^[A-Za-z_][A-Za-z0-9_]*$/;
|
|
|
20
12
|
* @returns Quoted identifier (e.g., "table_name")
|
|
21
13
|
* @throws Error if identifier contains unsupported characters
|
|
22
14
|
*/
|
|
23
|
-
function quoteIdentifier(identifier) {
|
|
15
|
+
export function quoteIdentifier(identifier) {
|
|
24
16
|
const parts = identifier.split(".");
|
|
25
17
|
if (parts.length === 0) {
|
|
26
|
-
throw new
|
|
18
|
+
throw new HazoValidationError({ code: 'HAZO_CONNECT_VALIDATION_ERROR', pkg: 'hazo_connect', message: 'Identifier cannot be empty' });
|
|
27
19
|
}
|
|
28
20
|
const quoted = parts.map(part => {
|
|
29
21
|
if (!identifierPattern.test(part)) {
|
|
30
|
-
throw new
|
|
22
|
+
throw new HazoValidationError({ code: 'HAZO_CONNECT_VALIDATION_ERROR', pkg: 'hazo_connect', message: `Identifier '${part}' contains unsupported characters` });
|
|
31
23
|
}
|
|
32
24
|
return `"${part}"`;
|
|
33
25
|
});
|
|
@@ -42,7 +34,7 @@ function quoteIdentifier(identifier) {
|
|
|
42
34
|
* @param value - Value to normalize
|
|
43
35
|
* @returns Normalized value
|
|
44
36
|
*/
|
|
45
|
-
function normalizeValue(value) {
|
|
37
|
+
export function normalizeValue(value) {
|
|
46
38
|
if (value === undefined) {
|
|
47
39
|
return null;
|
|
48
40
|
}
|
|
@@ -59,7 +51,7 @@ function normalizeValue(value) {
|
|
|
59
51
|
* @param value - Value to check
|
|
60
52
|
* @returns True if value is a plain object
|
|
61
53
|
*/
|
|
62
|
-
function isPlainObject(value) {
|
|
54
|
+
export function isPlainObject(value) {
|
|
63
55
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
64
56
|
}
|
|
65
57
|
/**
|
|
@@ -68,10 +60,10 @@ function isPlainObject(value) {
|
|
|
68
60
|
* @returns Sanitized table name
|
|
69
61
|
* @throws Error if table name is empty
|
|
70
62
|
*/
|
|
71
|
-
function sanitizeTableName(table) {
|
|
63
|
+
export function sanitizeTableName(table) {
|
|
72
64
|
const trimmed = table.trim();
|
|
73
65
|
if (!trimmed) {
|
|
74
|
-
throw new
|
|
66
|
+
throw new HazoValidationError({ code: 'HAZO_CONNECT_VALIDATION_ERROR', pkg: 'hazo_connect', message: 'Table name cannot be empty' });
|
|
75
67
|
}
|
|
76
68
|
return trimmed;
|
|
77
69
|
}
|
|
@@ -80,14 +72,14 @@ function sanitizeTableName(table) {
|
|
|
80
72
|
* @param identifier - Identifier to validate
|
|
81
73
|
* @returns True if identifier is valid
|
|
82
74
|
*/
|
|
83
|
-
function validateIdentifier(identifier) {
|
|
75
|
+
export function validateIdentifier(identifier) {
|
|
84
76
|
return identifierPattern.test(identifier);
|
|
85
77
|
}
|
|
86
78
|
/**
|
|
87
79
|
* Get the identifier pattern regex (for use in other modules if needed)
|
|
88
80
|
* @returns The identifier pattern regex
|
|
89
81
|
*/
|
|
90
|
-
function getIdentifierPattern() {
|
|
82
|
+
export function getIdentifierPattern() {
|
|
91
83
|
return identifierPattern;
|
|
92
84
|
}
|
|
93
85
|
//# sourceMappingURL=sqlite-utils.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sqlite-utils.js","sourceRoot":"","sources":["../../src/lib/utils/sqlite-utils.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"sqlite-utils.js","sourceRoot":"","sources":["../../src/lib/utils/sqlite-utils.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,mBAAmB,EAAE,MAAM,WAAW,CAAA;AAE/C,MAAM,iBAAiB,GAAG,0BAA0B,CAAA;AAEpD;;;;;GAKG;AACH,MAAM,UAAU,eAAe,CAAC,UAAkB;IAChD,MAAM,KAAK,GAAG,UAAU,CAAC,KAAK,CAAC,GAAG,CAAC,CAAA;IACnC,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACvB,MAAM,IAAI,mBAAmB,CAAC,EAAE,IAAI,EAAE,+BAA+B,EAAE,GAAG,EAAE,cAAc,EAAE,OAAO,EAAE,4BAA4B,EAAE,CAAC,CAAA;IACtI,CAAC;IAED,MAAM,MAAM,GAAG,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE;QAC9B,IAAI,CAAC,iBAAiB,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC;YAClC,MAAM,IAAI,mBAAmB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AAC,UAAU,CAAC,CAAA;AAC3C,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,oBAAoB;IAClC,OAAO,iBAAiB,CAAA;AAC1B,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wasm-resolver.d.ts","sourceRoot":"","sources":["../../src/lib/utils/wasm-resolver.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;
|
|
1
|
+
{"version":3,"file":"wasm-resolver.d.ts","sourceRoot":"","sources":["../../src/lib/utils/wasm-resolver.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAmDH,MAAM,WAAW,kBAAkB;IACjC,cAAc,CAAC,EAAE,MAAM,CAAA;CACxB;AAED,MAAM,WAAW,WAAW;IAC1B,UAAU,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,MAAM,CAAA;CACrC;AAED;;;;GAIG;AACH,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,kBAAkB,GAAG,MAAM,CA4CvE;AAED;;;;GAIG;AACH,wBAAgB,iBAAiB,CAAC,aAAa,EAAE,MAAM,GAAG,WAAW,CAsCpE"}
|
|
@@ -1,20 +1,44 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
/**
|
|
3
2
|
* Purpose: WASM file path resolution for sql.js in various environments (Node.js, Next.js, etc.)
|
|
4
3
|
*
|
|
5
4
|
* This module handles locating the sql-wasm.wasm file needed by sql.js,
|
|
6
5
|
* with special handling for Next.js server components and different deployment scenarios.
|
|
7
6
|
*/
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
};
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
7
|
+
import fs from "fs";
|
|
8
|
+
import path from "path";
|
|
9
|
+
import { fileURLToPath } from "url";
|
|
10
|
+
// Directory this module was loaded from. Strategy 1 walks up from here so a
|
|
11
|
+
// nested install (the consuming app has its own sql.js, hazo_connect has
|
|
12
|
+
// another under its own node_modules/) still finds the copy that belongs to
|
|
13
|
+
// this package rather than whichever one happens to sit above process.cwd().
|
|
14
|
+
//
|
|
15
|
+
// Deliberately NOT `createRequire(...).resolve('sql.js/dist/sql-wasm.wasm')`,
|
|
16
|
+
// which is what this used to do. Turbopack statically analyses a resolve() call
|
|
17
|
+
// whose argument ends in `.wasm`, turns it into a WebAssembly asset, and then
|
|
18
|
+
// panics emitting the trace for it:
|
|
19
|
+
// NftJsonAsset: cannot handle filepath '[turbopack-wasm]/node/loadWasm.ts'
|
|
20
|
+
// That aborted `next build` outright in a consuming app. A plain fs lookup
|
|
21
|
+
// finds the same file and gives no bundler anything to misread.
|
|
22
|
+
const MODULE_DIR = path.dirname(fileURLToPath(import.meta.url));
|
|
23
|
+
/** Walk up from `startDir` looking for node_modules/sql.js/dist/sql-wasm.wasm. */
|
|
24
|
+
function findWasmDirUpwards(startDir) {
|
|
25
|
+
let dir = startDir;
|
|
26
|
+
while (true) {
|
|
27
|
+
const wasmPath = path.join(dir, 'node_modules', 'sql.js', 'dist', 'sql-wasm.wasm');
|
|
28
|
+
if (fs.existsSync(wasmPath)) {
|
|
29
|
+
return path.dirname(wasmPath);
|
|
30
|
+
}
|
|
31
|
+
const parent = path.dirname(dir);
|
|
32
|
+
if (parent === dir)
|
|
33
|
+
return null;
|
|
34
|
+
dir = parent;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
// Ensure CommonJS module object exists for sql.js compatibility in Next.js ESM context
|
|
38
|
+
// sql.js checks typeof module !== 'undefined' but then tries to set module.exports
|
|
39
|
+
// In Next.js bundling, module may be defined but undefined, causing the error
|
|
40
|
+
// We need to ensure module is a proper object before sql.js loads
|
|
41
|
+
;
|
|
18
42
|
(function () {
|
|
19
43
|
// @ts-ignore - Define module for sql.js compatibility
|
|
20
44
|
if (typeof module === 'undefined' || !module || typeof module.exports === 'undefined') {
|
|
@@ -32,61 +56,38 @@ const nodeRequire = (0, module_1.createRequire)(__filename);
|
|
|
32
56
|
* @param config - Configuration with optional wasm_directory
|
|
33
57
|
* @returns Path to WASM directory (file system path or URL indicator)
|
|
34
58
|
*/
|
|
35
|
-
function resolveWasmDirectory(config) {
|
|
59
|
+
export function resolveWasmDirectory(config) {
|
|
36
60
|
if (config.wasm_directory) {
|
|
37
61
|
// If it's already a URL path (starts with /), return as-is for Next.js
|
|
38
|
-
if (config.wasm_directory.startsWith('/') && !
|
|
62
|
+
if (config.wasm_directory.startsWith('/') && !path.isAbsolute(config.wasm_directory)) {
|
|
39
63
|
return config.wasm_directory;
|
|
40
64
|
}
|
|
41
65
|
// Otherwise resolve as file system path
|
|
42
|
-
return
|
|
66
|
+
return path.resolve(config.wasm_directory);
|
|
43
67
|
}
|
|
44
68
|
// Try multiple strategies to find the WASM file
|
|
45
69
|
const strategies = [
|
|
46
|
-
// Strategy 1:
|
|
47
|
-
()
|
|
48
|
-
|
|
49
|
-
const resolved = nodeRequire.resolve('sql.js/dist/sql-wasm.wasm');
|
|
50
|
-
if (fs_1.default.existsSync(resolved)) {
|
|
51
|
-
return path_1.default.dirname(resolved);
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
catch {
|
|
55
|
-
// Ignore
|
|
56
|
-
}
|
|
57
|
-
return null;
|
|
58
|
-
},
|
|
70
|
+
// Strategy 1: Walk up from this module — finds the sql.js that ships
|
|
71
|
+
// alongside hazo_connect, including a nested (non-hoisted) install.
|
|
72
|
+
() => findWasmDirUpwards(MODULE_DIR),
|
|
59
73
|
// Strategy 2: Try public directory (for Next.js)
|
|
60
74
|
() => {
|
|
61
|
-
const publicPath =
|
|
62
|
-
if (
|
|
63
|
-
return
|
|
75
|
+
const publicPath = path.join(process.cwd(), 'public', 'sql-wasm.wasm');
|
|
76
|
+
if (fs.existsSync(publicPath)) {
|
|
77
|
+
return path.join(process.cwd(), 'public');
|
|
64
78
|
}
|
|
65
79
|
return null;
|
|
66
80
|
},
|
|
67
81
|
// Strategy 3: Try node_modules relative to cwd
|
|
68
82
|
() => {
|
|
69
|
-
const nodeModulesPath =
|
|
70
|
-
if (
|
|
71
|
-
return
|
|
83
|
+
const nodeModulesPath = path.join(process.cwd(), 'node_modules', 'sql.js', 'dist', 'sql-wasm.wasm');
|
|
84
|
+
if (fs.existsSync(nodeModulesPath)) {
|
|
85
|
+
return path.join(process.cwd(), 'node_modules', 'sql.js', 'dist');
|
|
72
86
|
}
|
|
73
87
|
return null;
|
|
74
88
|
},
|
|
75
89
|
// Strategy 4: Walk up from cwd — handles npm workspaces where node_modules is hoisted
|
|
76
|
-
() =>
|
|
77
|
-
let dir = process.cwd();
|
|
78
|
-
while (true) {
|
|
79
|
-
const wasmPath = path_1.default.join(dir, 'node_modules', 'sql.js', 'dist', 'sql-wasm.wasm');
|
|
80
|
-
if (fs_1.default.existsSync(wasmPath)) {
|
|
81
|
-
return path_1.default.join(dir, 'node_modules', 'sql.js', 'dist');
|
|
82
|
-
}
|
|
83
|
-
const parent = path_1.default.dirname(dir);
|
|
84
|
-
if (parent === dir)
|
|
85
|
-
break;
|
|
86
|
-
dir = parent;
|
|
87
|
-
}
|
|
88
|
-
return null;
|
|
89
|
-
}
|
|
90
|
+
() => findWasmDirUpwards(process.cwd())
|
|
90
91
|
];
|
|
91
92
|
for (const strategy of strategies) {
|
|
92
93
|
const result = strategy();
|
|
@@ -102,34 +103,34 @@ function resolveWasmDirectory(config) {
|
|
|
102
103
|
* @param wasmDirectory - Directory path (file system or URL indicator)
|
|
103
104
|
* @returns sql.js configuration object
|
|
104
105
|
*/
|
|
105
|
-
function createSqlJsConfig(wasmDirectory) {
|
|
106
|
+
export function createSqlJsConfig(wasmDirectory) {
|
|
106
107
|
return {
|
|
107
108
|
locateFile: (file) => {
|
|
108
109
|
// sql.js in Node.js uses fs.readFileSync, so we need actual file system paths
|
|
109
110
|
// If wasmDirectory is a URL path indicator (starts with /), resolve to actual file path
|
|
110
|
-
if (wasmDirectory === '/' || (wasmDirectory.startsWith('/') && !
|
|
111
|
+
if (wasmDirectory === '/' || (wasmDirectory.startsWith('/') && !path.isAbsolute(wasmDirectory))) {
|
|
111
112
|
// Try public directory first (where we copied the WASM file)
|
|
112
|
-
const publicPath =
|
|
113
|
-
if (
|
|
113
|
+
const publicPath = path.join(process.cwd(), 'public', file);
|
|
114
|
+
if (fs.existsSync(publicPath)) {
|
|
114
115
|
return publicPath;
|
|
115
116
|
}
|
|
116
117
|
// Fallback to node_modules
|
|
117
|
-
const nodeModulesPath =
|
|
118
|
-
if (
|
|
118
|
+
const nodeModulesPath = path.join(process.cwd(), 'node_modules', 'sql.js', 'dist', file);
|
|
119
|
+
if (fs.existsSync(nodeModulesPath)) {
|
|
119
120
|
return nodeModulesPath;
|
|
120
121
|
}
|
|
121
122
|
// Return public path anyway (sql.js will show a clearer error)
|
|
122
123
|
return publicPath;
|
|
123
124
|
}
|
|
124
125
|
// Use file system path directly
|
|
125
|
-
const fullPath =
|
|
126
|
+
const fullPath = path.join(wasmDirectory, file);
|
|
126
127
|
// Verify the file exists
|
|
127
|
-
if (
|
|
128
|
+
if (fs.existsSync(fullPath)) {
|
|
128
129
|
return fullPath;
|
|
129
130
|
}
|
|
130
131
|
// Fallback: try public directory
|
|
131
|
-
const publicPath =
|
|
132
|
-
if (
|
|
132
|
+
const publicPath = path.join(process.cwd(), 'public', file);
|
|
133
|
+
if (fs.existsSync(publicPath)) {
|
|
133
134
|
return publicPath;
|
|
134
135
|
}
|
|
135
136
|
// Last resort: return the constructed path
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wasm-resolver.js","sourceRoot":"","sources":["../../src/lib/utils/wasm-resolver.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"wasm-resolver.js","sourceRoot":"","sources":["../../src/lib/utils/wasm-resolver.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,MAAM,IAAI,CAAA;AACnB,OAAO,IAAI,MAAM,MAAM,CAAA;AACvB,OAAO,EAAE,aAAa,EAAE,MAAM,KAAK,CAAA;AAEnC,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E,IAAI,CAAC,CAAA;YAE/C,yBAAyB;YACzB,IAAI,EAAE,CAAC,UAAU,CAAC,QAAQ,CAAC,EAAE,CAAC;gBAC5B,OAAO,QAAQ,CAAA;YACjB,CAAC;YAED,iCAAiC;YACjC,MAAM,UAAU,GAAG,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,QAAQ,EAAE,IAAI,CAAC,CAAA;YAC3D,IAAI,EAAE,CAAC,UAAU,CAAC,UAAU,CAAC,EAAE,CAAC;gBAC9B,OAAO,UAAU,CAAA;YACnB,CAAC;YAED,2CAA2C;YAC3C,OAAO,QAAQ,CAAA;QACjB,CAAC;KACF,CAAA;AACH,CAAC"}
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* This module provides shared logic for building WHERE clauses from filter conditions,
|
|
5
5
|
* used by both the query translator and admin service.
|
|
6
6
|
*/
|
|
7
|
-
import type { WhereCondition } from "../types";
|
|
7
|
+
import type { WhereCondition } from "../types.js";
|
|
8
8
|
export interface WhereClauseResult {
|
|
9
9
|
clause: string;
|
|
10
10
|
params: unknown[];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"where-builder.d.ts","sourceRoot":"","sources":["../../src/lib/utils/where-builder.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,KAAK,EAAiB,cAAc,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"where-builder.d.ts","sourceRoot":"","sources":["../../src/lib/utils/where-builder.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,KAAK,EAAiB,cAAc,EAAE,MAAM,aAAa,CAAA;AAGhE,MAAM,WAAW,iBAAiB;IAChC,MAAM,EAAE,MAAM,CAAA;IACd,MAAM,EAAE,OAAO,EAAE,CAAA;CAClB;AAED,MAAM,MAAM,oBAAoB,GAC5B,IAAI,GACJ,KAAK,GACL,IAAI,GACJ,KAAK,GACL,IAAI,GACJ,KAAK,GACL,MAAM,GACN,OAAO,GACP,IAAI,GACJ,IAAI,CAAA;AAER,MAAM,WAAW,iBAAiB;IAChC,MAAM,EAAE,MAAM,CAAA;IACd,QAAQ,EAAE,oBAAoB,CAAA;IAC9B,KAAK,EAAE,OAAO,CAAA;CACf;AAED;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAC9B,OAAO,EAAE,iBAAiB,EAAE,GAAG,cAAc,EAAE,EAC/C,UAAU,GAAE,CAAC,KAAK,EAAE,MAAM,KAAK,MAAwB,GACtD,iBAAiB,CAgBnB;AAED;;;;;GAKG;AACH,wBAAgB,uBAAuB,CACrC,SAAS,EAAE,iBAAiB,GAAG,cAAc,EAC7C,UAAU,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,MAAM,GACpC;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,OAAO,EAAE,CAAA;CAAE,CAkEvC;AAED;;;;GAIG;AACH,wBAAgB,wBAAwB,CACtC,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAChC,iBAAiB,EAAE,CAMrB"}
|
|
@@ -1,23 +1,18 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
/**
|
|
3
2
|
* Purpose: Unified WHERE clause builder for SQLite queries.
|
|
4
3
|
*
|
|
5
4
|
* This module provides shared logic for building WHERE clauses from filter conditions,
|
|
6
5
|
* used by both the query translator and admin service.
|
|
7
6
|
*/
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
exports.translateWhereCondition = translateWhereCondition;
|
|
11
|
-
exports.buildFiltersFromCriteria = buildFiltersFromCriteria;
|
|
12
|
-
const hazo_core_1 = require("hazo_core");
|
|
13
|
-
const sqlite_utils_1 = require("./sqlite-utils");
|
|
7
|
+
import { HazoValidationError } from 'hazo_core';
|
|
8
|
+
import { quoteIdentifier, normalizeValue } from "./sqlite-utils.js";
|
|
14
9
|
/**
|
|
15
10
|
* Build a WHERE clause from an array of filter conditions
|
|
16
11
|
* @param filters - Array of filter conditions
|
|
17
12
|
* @param quoteField - Function to quote field names (defaults to quoteIdentifier)
|
|
18
13
|
* @returns WHERE clause SQL and parameter array
|
|
19
14
|
*/
|
|
20
|
-
function buildWhereClause(filters, quoteField =
|
|
15
|
+
export function buildWhereClause(filters, quoteField = quoteIdentifier) {
|
|
21
16
|
if (!filters || filters.length === 0) {
|
|
22
17
|
return { clause: "", params: [] };
|
|
23
18
|
}
|
|
@@ -37,7 +32,7 @@ function buildWhereClause(filters, quoteField = sqlite_utils_1.quoteIdentifier)
|
|
|
37
32
|
* @param quoteField - Function to quote field names
|
|
38
33
|
* @returns SQL clause and parameters
|
|
39
34
|
*/
|
|
40
|
-
function translateWhereCondition(condition, quoteField) {
|
|
35
|
+
export function translateWhereCondition(condition, quoteField) {
|
|
41
36
|
const operator = condition.operator;
|
|
42
37
|
// Handle both WhereCondition (has 'field') and SqliteWhereFilter (has 'column')
|
|
43
38
|
const fieldName = 'field' in condition ? condition.field : condition.column;
|
|
@@ -49,22 +44,22 @@ function translateWhereCondition(condition, quoteField) {
|
|
|
49
44
|
if (value === null || value === undefined) {
|
|
50
45
|
return { clause: `${field} IS NULL`, params };
|
|
51
46
|
}
|
|
52
|
-
return { clause: `${field} = ?`, params: [
|
|
47
|
+
return { clause: `${field} = ?`, params: [normalizeValue(value)] };
|
|
53
48
|
}
|
|
54
49
|
case "neq": {
|
|
55
50
|
if (value === null || value === undefined) {
|
|
56
51
|
return { clause: `${field} IS NOT NULL`, params };
|
|
57
52
|
}
|
|
58
|
-
return { clause: `${field} != ?`, params: [
|
|
53
|
+
return { clause: `${field} != ?`, params: [normalizeValue(value)] };
|
|
59
54
|
}
|
|
60
55
|
case "gt":
|
|
61
|
-
return { clause: `${field} > ?`, params: [
|
|
56
|
+
return { clause: `${field} > ?`, params: [normalizeValue(value)] };
|
|
62
57
|
case "gte":
|
|
63
|
-
return { clause: `${field} >= ?`, params: [
|
|
58
|
+
return { clause: `${field} >= ?`, params: [normalizeValue(value)] };
|
|
64
59
|
case "lt":
|
|
65
|
-
return { clause: `${field} < ?`, params: [
|
|
60
|
+
return { clause: `${field} < ?`, params: [normalizeValue(value)] };
|
|
66
61
|
case "lte":
|
|
67
|
-
return { clause: `${field} <= ?`, params: [
|
|
62
|
+
return { clause: `${field} <= ?`, params: [normalizeValue(value)] };
|
|
68
63
|
case "like": {
|
|
69
64
|
return { clause: `${field} LIKE ?`, params: [String(value ?? "")] };
|
|
70
65
|
}
|
|
@@ -87,7 +82,7 @@ function translateWhereCondition(condition, quoteField) {
|
|
|
87
82
|
return { clause: `${field} IS NOT NULL`, params };
|
|
88
83
|
}
|
|
89
84
|
else {
|
|
90
|
-
throw new
|
|
85
|
+
throw new HazoValidationError({ code: 'HAZO_CONNECT_VALIDATION_ERROR', pkg: 'hazo_connect', message: `Unsupported value '${JSON.stringify(value)}' for IS operator. Use null, 'not.null', or { isNotNull: true }.` });
|
|
91
86
|
}
|
|
92
87
|
}
|
|
93
88
|
case "in": {
|
|
@@ -98,11 +93,11 @@ function translateWhereCondition(condition, quoteField) {
|
|
|
98
93
|
const placeholders = values.map(() => "?").join(", ");
|
|
99
94
|
return {
|
|
100
95
|
clause: `${field} IN (${placeholders})`,
|
|
101
|
-
params: values.map(
|
|
96
|
+
params: values.map(normalizeValue)
|
|
102
97
|
};
|
|
103
98
|
}
|
|
104
99
|
default:
|
|
105
|
-
throw new
|
|
100
|
+
throw new HazoValidationError({ code: 'HAZO_CONNECT_VALIDATION_ERROR', pkg: 'hazo_connect', message: `Unsupported filter operator '${operator}'` });
|
|
106
101
|
}
|
|
107
102
|
}
|
|
108
103
|
/**
|
|
@@ -110,7 +105,7 @@ function translateWhereCondition(condition, quoteField) {
|
|
|
110
105
|
* @param criteria - Object with column names as keys and values
|
|
111
106
|
* @returns Array of filter conditions
|
|
112
107
|
*/
|
|
113
|
-
function buildFiltersFromCriteria(criteria) {
|
|
108
|
+
export function buildFiltersFromCriteria(criteria) {
|
|
114
109
|
return Object.entries(criteria).map(([column, value]) => ({
|
|
115
110
|
column,
|
|
116
111
|
operator: "eq",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"where-builder.js","sourceRoot":"","sources":["../../src/lib/utils/where-builder.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"where-builder.js","sourceRoot":"","sources":["../../src/lib/utils/where-builder.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,mBAAmB,EAAE,MAAM,WAAW,CAAA;AAE/C,OAAO,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAA;AAyBnE;;;;;GAKG;AACH,MAAM,UAAU,gBAAgB,CAC9B,OAA+C,EAC/C,aAAwC,eAAe;IAEvD,IAAI,CAAC,OAAO,IAAI,OAAO,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACrC,OAAO,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,CAAA;IACnC,CAAC;IAED,MAAM,OAAO,GAAa,EAAE,CAAA;IAC5B,MAAM,MAAM,GAAc,EAAE,CAAA;IAE5B,KAAK,MAAM,MAAM,IAAI,OAAO,EAAE,CAAC;QAC7B,MAAM,SAAS,GAAG,uBAAuB,CAAC,MAAM,EAAE,UAAU,CAAC,CAAA;QAC7D,OAAO,CAAC,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,CAAA;QAC9B,MAAM,CAAC,IAAI,CAAC,GAAG,SAAS,CAAC,MAAM,CAAC,CAAA;IAClC,CAAC;IAED,MAAM,SAAS,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,UAAU,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,CAAA;IACzE,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,CAAA;AACtC,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,uBAAuB,CACrC,SAA6C,EAC7C,UAAqC;IAErC,MAAM,QAAQ,GAAG,SAAS,CAAC,QA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KACN,CAAC,CAAC,CAAA;AACL,CAAC"}
|
package/docs/migration-guide.md
CHANGED
|
@@ -4,11 +4,47 @@ This guide helps you migrate existing code to use the new server-side entry poin
|
|
|
4
4
|
|
|
5
5
|
## Table of Contents
|
|
6
6
|
|
|
7
|
+
- [3.x → 4.0: CommonJS to ESM](#3x--40-commonjs-to-esm)
|
|
7
8
|
- [From Old Import Paths](#from-old-import-paths)
|
|
8
9
|
- [From Client-Side to Server-Side](#from-client-side-to-server-side)
|
|
9
10
|
- [From Direct Calls to API Routes](#from-direct-calls-to-api-routes)
|
|
10
11
|
- [Testing Considerations](#testing-considerations)
|
|
11
12
|
|
|
13
|
+
## 3.x → 4.0: CommonJS to ESM
|
|
14
|
+
|
|
15
|
+
4.0.0 ships the package as ES modules (`"type": "module"`). Entry points,
|
|
16
|
+
exports, and every runtime API are unchanged — only the module format moved.
|
|
17
|
+
|
|
18
|
+
### What breaks
|
|
19
|
+
|
|
20
|
+
Only `require()`. If your code already uses `import`, or you consume the
|
|
21
|
+
package through a bundler (Next.js, Vite, webpack), there is nothing to do.
|
|
22
|
+
|
|
23
|
+
```javascript
|
|
24
|
+
// Before — CommonJS consumer
|
|
25
|
+
const { createHazoConnect } = require('hazo_connect/server')
|
|
26
|
+
|
|
27
|
+
// After — option 1: convert the file to ESM
|
|
28
|
+
import { createHazoConnect } from 'hazo_connect/server'
|
|
29
|
+
|
|
30
|
+
// After — option 2: keep the file CommonJS, load dynamically
|
|
31
|
+
const { createHazoConnect } = await import('hazo_connect/server')
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
### If you were pinned by a peer
|
|
35
|
+
|
|
36
|
+
`hazo_core` has always been ESM-only. If you were working around the old CJS
|
|
37
|
+
build — for example forcing a sequential `await import('hazo_core')` before
|
|
38
|
+
loading `hazo_connect` to dodge `ERR_REQUIRE_ESM_RACE_CONDITION` — that
|
|
39
|
+
workaround is no longer needed and can be removed once you are on 4.0.0.
|
|
40
|
+
|
|
41
|
+
### Bin and postinstall scripts
|
|
42
|
+
|
|
43
|
+
`scripts/setup-routes.js` and `scripts/postinstall-setup.js` are now
|
|
44
|
+
`.cjs` files, since they are CommonJS and the package root is ESM. The
|
|
45
|
+
`npx hazo-connect-setup-routes` command is unchanged; only update references
|
|
46
|
+
if you invoked the script by its file path.
|
|
47
|
+
|
|
12
48
|
## From Old Import Paths
|
|
13
49
|
|
|
14
50
|
### Before (Old Import)
|
package/docs/troubleshooting.md
CHANGED
|
@@ -12,6 +12,48 @@ This guide helps you resolve common issues when using `hazo_connect` in Next.js
|
|
|
12
12
|
|
|
13
13
|
## Common Errors
|
|
14
14
|
|
|
15
|
+
### Error: `ERR_REQUIRE_ESM_RACE_CONDITION` loading hazo_core
|
|
16
|
+
|
|
17
|
+
**Symptoms:**
|
|
18
|
+
```
|
|
19
|
+
Failed to load external module hazo_connect/server: Error
|
|
20
|
+
[ERR_REQUIRE_ESM_RACE_CONDITION]: Cannot require() ES Module
|
|
21
|
+
.../hazo_core/dist/index.js because it is not yet fully loaded.
|
|
22
|
+
```
|
|
23
|
+
In a Next.js app this usually appears as "An error occurred while loading
|
|
24
|
+
instrumentation hook", and every request 500s.
|
|
25
|
+
|
|
26
|
+
**Cause:** You are on hazo_connect 3.x, which was built as CommonJS and
|
|
27
|
+
therefore `require()`d the ESM-only `hazo_core`. Node allows that, but throws
|
|
28
|
+
if `hazo_core` is still mid-evaluation from a concurrent `import()` — which is
|
|
29
|
+
what Turbopack produces when it resolves `serverExternalPackages` in parallel.
|
|
30
|
+
|
|
31
|
+
**Solution:** Upgrade to hazo_connect >= 4.0.0, which ships ESM and never
|
|
32
|
+
`require()`s anything. As a stopgap on 3.x, load `hazo_core` to completion
|
|
33
|
+
first so the later `require()` is a cache hit:
|
|
34
|
+
|
|
35
|
+
```javascript
|
|
36
|
+
await import('hazo_core') // must finish before the next line
|
|
37
|
+
const { createHazoConnect } = await import('hazo_connect/server')
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
### Error: `NftJsonAsset: cannot handle filepath '[turbopack-wasm]/node/loadWasm.ts'`
|
|
41
|
+
|
|
42
|
+
**Symptoms:** `next build` aborts with a Turbopack panic:
|
|
43
|
+
```
|
|
44
|
+
FATAL: An unexpected Turbopack error occurred.
|
|
45
|
+
Error [TurbopackInternalError]: NftJsonAsset: cannot handle filepath
|
|
46
|
+
'[turbopack-wasm]/node/loadWasm.ts', it is not under the output_root
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
**Cause:** hazo_connect < 4.0.0 located sql.js's WASM file with
|
|
50
|
+
`require.resolve('sql.js/dist/sql-wasm.wasm')`. Turbopack analyses that call
|
|
51
|
+
statically, promotes the `.wasm` to a WebAssembly asset, and then panics
|
|
52
|
+
emitting its file trace.
|
|
53
|
+
|
|
54
|
+
**Solution:** Upgrade to hazo_connect >= 4.0.0, which finds the same file with
|
|
55
|
+
a plain filesystem walk and gives the bundler nothing to analyse.
|
|
56
|
+
|
|
15
57
|
### Error: "Cannot set properties of undefined (setting 'exports')"
|
|
16
58
|
|
|
17
59
|
**Symptoms:**
|