hazo_connect 2.4.5 → 2.4.6
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/README.md +41 -0
- package/dist/helpers.d.ts.map +1 -1
- package/dist/helpers.js +67 -11
- package/dist/helpers.js.map +1 -1
- package/package.json +5 -2
- package/app/hazo_connect/api/sqlite/data/route.ts +0 -197
- package/app/hazo_connect/api/sqlite/schema/route.ts +0 -34
- package/app/hazo_connect/api/sqlite/tables/route.ts +0 -25
- package/app/hazo_connect/middleware.ts +0 -40
- package/app/hazo_connect/sqlite_admin/page.tsx +0 -29
package/README.md
CHANGED
|
@@ -524,6 +524,47 @@ const hazo = createHazoConnect({
|
|
|
524
524
|
|
|
525
525
|
See [docs/logging.md](docs/logging.md) for detailed configuration options.
|
|
526
526
|
|
|
527
|
+
### Debug Integration (hazo_debug)
|
|
528
|
+
|
|
529
|
+
hazo_connect emits structured `query_executed` and `query_failed` log entries at DEBUG level with timing data. You can forward these to [hazo_debug](https://github.com/pub12/hazo_debug)'s SQL tab by passing a custom logger:
|
|
530
|
+
|
|
531
|
+
```typescript
|
|
532
|
+
import { createCrudService } from 'hazo_connect/server';
|
|
533
|
+
import { use_debug_query } from 'hazo_debug/client';
|
|
534
|
+
|
|
535
|
+
// In your React component or provider:
|
|
536
|
+
const { log_query } = use_debug_query();
|
|
537
|
+
|
|
538
|
+
const debug_logger = {
|
|
539
|
+
debug: (msg: string, data?: Record<string, unknown>) => {
|
|
540
|
+
if (msg === 'query_executed') log_query(data);
|
|
541
|
+
},
|
|
542
|
+
info: () => {},
|
|
543
|
+
warn: () => {},
|
|
544
|
+
error: (msg: string, data?: Record<string, unknown>) => {
|
|
545
|
+
if (msg === 'query_failed') log_query(data);
|
|
546
|
+
},
|
|
547
|
+
};
|
|
548
|
+
|
|
549
|
+
const service = createCrudService(adapter, 'hazo_users', {
|
|
550
|
+
logger: debug_logger,
|
|
551
|
+
});
|
|
552
|
+
```
|
|
553
|
+
|
|
554
|
+
The structured log entries include:
|
|
555
|
+
|
|
556
|
+
| Field | Type | Description |
|
|
557
|
+
|-------|------|-------------|
|
|
558
|
+
| `operation` | `string` | `SELECT`, `INSERT`, `UPDATE`, or `DELETE` |
|
|
559
|
+
| `table` | `string` | Table name being queried |
|
|
560
|
+
| `duration_ms` | `number` | Query execution time in milliseconds |
|
|
561
|
+
| `rows_returned` | `number?` | Number of rows returned (SELECT) |
|
|
562
|
+
| `rows_affected` | `number?` | Number of rows affected (INSERT/UPDATE/DELETE) |
|
|
563
|
+
| `adapter` | `string?` | Adapter class name (e.g., `SqliteAdapter`) |
|
|
564
|
+
| `error` | `string?` | Error message (only on `query_failed`) |
|
|
565
|
+
|
|
566
|
+
**Note:** hazo_debug is an optional peer dependency. hazo_connect does NOT import it — the integration works entirely through the Logger interface.
|
|
567
|
+
|
|
527
568
|
---
|
|
528
569
|
|
|
529
570
|
## Key Interfaces
|
package/dist/helpers.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../src/lib/helpers.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAIH,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAA;AACjD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,EAAE,MAAM,YAAY,CAAA;AAE5D;;GAEG;AACH,MAAM,MAAM,WAAW,GAAG,KAAK,GAAG,MAAM,GAAG,KAAK,GAAG,OAAO,GAAG,QAAQ,CAAA;
|
|
1
|
+
{"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../src/lib/helpers.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAIH,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAA;AACjD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,EAAE,MAAM,YAAY,CAAA;AAE5D;;GAEG;AACH,MAAM,MAAM,WAAW,GAAG,KAAK,GAAG,MAAM,GA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CAAA;IACvD,SAAS,CAAC,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,OAAO,CAAC,CAAC,GAAG,IAAI,CAAC,CAAA;IAC/D,QAAQ,CAAC,EAAE,EAAE,OAAO,GAAG,OAAO,CAAC,CAAC,GAAG,IAAI,CAAC,CAAA;IACxC,MAAM,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,EAAE,GAAG,OAAO,CAAC,CAAC,EAAE,CAAC,CAAA;IACrD,UAAU,CAAC,EAAE,EAAE,OAAO,EAAE,KAAK,EAAE,OAAO,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,EAAE,CAAC,CAAA;IACxD,UAAU,CAAC,EAAE,EAAE,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;IACtC,KAAK,IAAI,sBAAsB,CAAA;CAChC;AAED;;;;;;GAMG;AACH,wBAAgB,iBAAiB,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC3F,OAAO,EAAE,kBAAkB,EAC3B,KAAK,EAAE,MAAM,EACb,OAAO,GAAE,kBAAuB,GAC/B,WAAW,CAAC,CAAC,CAAC,CA+HhB;AAED;;;;;;;;GAQG;AACH,wBAAsB,YAAY,CAChC,OAAO,EAAE,kBAAkB,EAC3B,OAAO,EAAE,YAAY,EACrB,MAAM,GAAE,WAAmB,EAC3B,IAAI,CAAC,EAAE,OAAO,EACd,MAAM,CAAC,EAAE,MAAM,GACd,OAAO,CAAC,OAAO,CAAC,CAgClB"}
|
package/dist/helpers.js
CHANGED
|
@@ -15,6 +15,19 @@ exports.createCrudService = createCrudService;
|
|
|
15
15
|
exports.executeQuery = executeQuery;
|
|
16
16
|
const crypto_1 = require("crypto");
|
|
17
17
|
const query_builder_js_1 = require("./query-builder.js");
|
|
18
|
+
/**
|
|
19
|
+
* Map HTTP method to SQL operation name for structured debug logging.
|
|
20
|
+
*/
|
|
21
|
+
function methodToOperation(method) {
|
|
22
|
+
switch (method.toUpperCase()) {
|
|
23
|
+
case 'GET': return 'SELECT';
|
|
24
|
+
case 'POST': return 'INSERT';
|
|
25
|
+
case 'PUT':
|
|
26
|
+
case 'PATCH': return 'UPDATE';
|
|
27
|
+
case 'DELETE': return 'DELETE';
|
|
28
|
+
default: return method.toUpperCase();
|
|
29
|
+
}
|
|
30
|
+
}
|
|
18
31
|
/**
|
|
19
32
|
* Create a query builder for a table and attach the adapter execute method.
|
|
20
33
|
* @param adapter - Active Hazo Connect adapter
|
|
@@ -36,12 +49,33 @@ function createTableQuery(adapter, table, logger) {
|
|
|
36
49
|
function attachExecute(builder, adapter, logger) {
|
|
37
50
|
const executable = builder;
|
|
38
51
|
executable.execute = async (method = 'GET', body) => {
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
52
|
+
const table = builder.getTable() || 'unknown';
|
|
53
|
+
const operation = methodToOperation(method);
|
|
54
|
+
const start = Date.now();
|
|
55
|
+
try {
|
|
56
|
+
const result = await adapter.query(builder, method, body);
|
|
57
|
+
const duration_ms = Date.now() - start;
|
|
58
|
+
logger?.debug?.('query_executed', {
|
|
59
|
+
operation,
|
|
60
|
+
table,
|
|
61
|
+
duration_ms,
|
|
62
|
+
rows_returned: Array.isArray(result) ? result.length : undefined,
|
|
63
|
+
rows_affected: typeof result?.count === 'number' ? result.count : undefined,
|
|
64
|
+
adapter: adapter.constructor?.name,
|
|
65
|
+
});
|
|
66
|
+
return result;
|
|
67
|
+
}
|
|
68
|
+
catch (error) {
|
|
69
|
+
const duration_ms = Date.now() - start;
|
|
70
|
+
logger?.error?.('query_failed', {
|
|
71
|
+
operation,
|
|
72
|
+
table,
|
|
73
|
+
duration_ms,
|
|
74
|
+
error: error instanceof Error ? error.message : String(error),
|
|
75
|
+
adapter: adapter.constructor?.name,
|
|
76
|
+
});
|
|
77
|
+
throw error;
|
|
78
|
+
}
|
|
45
79
|
};
|
|
46
80
|
return executable;
|
|
47
81
|
}
|
|
@@ -177,10 +211,32 @@ function createCrudService(adapter, table, options = {}) {
|
|
|
177
211
|
* @returns Result of adapter query
|
|
178
212
|
*/
|
|
179
213
|
async function executeQuery(adapter, builder, method = 'GET', body, logger) {
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
214
|
+
const table = builder.getTable() || 'unknown';
|
|
215
|
+
const operation = methodToOperation(method);
|
|
216
|
+
const start = Date.now();
|
|
217
|
+
try {
|
|
218
|
+
const result = await adapter.query(builder, method, body);
|
|
219
|
+
const duration_ms = Date.now() - start;
|
|
220
|
+
logger?.debug?.('query_executed', {
|
|
221
|
+
operation,
|
|
222
|
+
table,
|
|
223
|
+
duration_ms,
|
|
224
|
+
rows_returned: Array.isArray(result) ? result.length : undefined,
|
|
225
|
+
rows_affected: typeof result?.count === 'number' ? result.count : undefined,
|
|
226
|
+
adapter: adapter.constructor?.name,
|
|
227
|
+
});
|
|
228
|
+
return result;
|
|
229
|
+
}
|
|
230
|
+
catch (error) {
|
|
231
|
+
const duration_ms = Date.now() - start;
|
|
232
|
+
logger?.error?.('query_failed', {
|
|
233
|
+
operation,
|
|
234
|
+
table,
|
|
235
|
+
duration_ms,
|
|
236
|
+
error: error instanceof Error ? error.message : String(error),
|
|
237
|
+
adapter: adapter.constructor?.name,
|
|
238
|
+
});
|
|
239
|
+
throw error;
|
|
240
|
+
}
|
|
185
241
|
}
|
|
186
242
|
//# sourceMappingURL=helpers.js.map
|
package/dist/helpers.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"helpers.js","sourceRoot":"","sources":["../src/lib/helpers.ts"],"names":[],"mappings":";AAAA;;;;;;;;GAQG;;
|
|
1
|
+
{"version":3,"file":"helpers.js","sourceRoot":"","sources":["../src/lib/helpers.ts"],"names":[],"mappings":";AAA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C,KAAK,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,CAAA;QACzD,MAAM,WAAW,GAAG,IAAI,CAAC,GAAG,EAAE,GAAG,KAAK,CAAA;QAEtC,MAAM,EAAE,KAAK,EAAE,CAAC,gBAAgB,EAAE;YAChC,SAAS;YACT,KAAK;YACL,WAAW;YACX,aAAa,EAAE,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,SAAS;YAChE,aAAa,EAAE,OAAO,MAAM,EAAE,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,SAAS;YAC3E,OAAO,EAAE,OAAO,CAAC,WAAW,EAAE,IAAI;SACnC,CAAC,CAAA;QAEF,OAAO,MAAM,CAAA;IACf,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,MAAM,WAAW,GAAG,IAAI,CAAC,GAAG,EAAE,GAAG,KAAK,CAAA;QAEtC,MAAM,EAAE,KAAK,EAAE,CAAC,cAAc,EAAE;YAC9B,SAAS;YACT,KAAK;YACL,WAAW;YACX,KAAK,EAAE,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC;YAC7D,OAAO,EAAE,OAAO,CAAC,WAAW,EAAE,IAAI;SACnC,CAAC,CAAA;QAEF,MAAM,KAAK,CAAA;IACb,CAAC;AACH,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "hazo_connect",
|
|
3
|
-
"version": "2.4.
|
|
3
|
+
"version": "2.4.6",
|
|
4
4
|
"description": "Module to connect to the data store (postgres via postgrest, supabase, etc)",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
7
7
|
"files": [
|
|
8
8
|
"dist",
|
|
9
|
-
"app/hazo_connect",
|
|
10
9
|
"scripts",
|
|
11
10
|
"docs",
|
|
12
11
|
"README.md"
|
|
@@ -77,6 +76,7 @@
|
|
|
77
76
|
},
|
|
78
77
|
"peerDependencies": {
|
|
79
78
|
"hazo_config": ">=1.3.0",
|
|
79
|
+
"hazo_debug": ">=1.0.0",
|
|
80
80
|
"hazo_logs": ">=1.0.5",
|
|
81
81
|
"lucide-react": "^0.553.0",
|
|
82
82
|
"next": ">=14.0.0",
|
|
@@ -88,6 +88,9 @@
|
|
|
88
88
|
"hazo_config": {
|
|
89
89
|
"optional": true
|
|
90
90
|
},
|
|
91
|
+
"hazo_debug": {
|
|
92
|
+
"optional": true
|
|
93
|
+
},
|
|
91
94
|
"lucide-react": {
|
|
92
95
|
"optional": true
|
|
93
96
|
},
|
|
@@ -1,197 +0,0 @@
|
|
|
1
|
-
import { NextRequest, NextResponse } from "next/server"
|
|
2
|
-
import {
|
|
3
|
-
getSqliteAdminService,
|
|
4
|
-
type RowQueryOptions,
|
|
5
|
-
type SqliteFilterOperator,
|
|
6
|
-
type SqliteWhereFilter
|
|
7
|
-
} from "hazo_connect/server"
|
|
8
|
-
import { getHazoConnectSingleton } from "hazo_connect/nextjs/setup"
|
|
9
|
-
|
|
10
|
-
export const dynamic = "force-dynamic"
|
|
11
|
-
const allowedOperators: SqliteFilterOperator[] = [
|
|
12
|
-
"eq",
|
|
13
|
-
"neq",
|
|
14
|
-
"gt",
|
|
15
|
-
"gte",
|
|
16
|
-
"lt",
|
|
17
|
-
"lte",
|
|
18
|
-
"like",
|
|
19
|
-
"ilike",
|
|
20
|
-
"is"
|
|
21
|
-
]
|
|
22
|
-
|
|
23
|
-
export async function GET(request: NextRequest) {
|
|
24
|
-
const url = new URL(request.url)
|
|
25
|
-
const table = url.searchParams.get("table")
|
|
26
|
-
if (!table) {
|
|
27
|
-
return NextResponse.json(
|
|
28
|
-
{ error: "Query parameter 'table' is required." },
|
|
29
|
-
{ status: 400 }
|
|
30
|
-
)
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
try {
|
|
34
|
-
// Initialize the singleton to ensure the adapter is registered with the admin service
|
|
35
|
-
getHazoConnectSingleton()
|
|
36
|
-
const service = getSqliteAdminService()
|
|
37
|
-
const options = parseRowQueryOptions(url.searchParams)
|
|
38
|
-
const page = await service.getTableData(table, options)
|
|
39
|
-
return NextResponse.json({ data: page.rows, total: page.total })
|
|
40
|
-
} catch (error) {
|
|
41
|
-
return toErrorResponse(error, `Failed to fetch data for table '${table}'`)
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
export async function POST(request: NextRequest) {
|
|
46
|
-
try {
|
|
47
|
-
// Initialize the singleton to ensure the adapter is registered with the admin service
|
|
48
|
-
getHazoConnectSingleton()
|
|
49
|
-
const service = getSqliteAdminService()
|
|
50
|
-
const payload = await request.json()
|
|
51
|
-
const table = payload?.table
|
|
52
|
-
const data = payload?.data
|
|
53
|
-
|
|
54
|
-
if (!table || typeof data !== "object" || Array.isArray(data)) {
|
|
55
|
-
return NextResponse.json(
|
|
56
|
-
{ error: "Request body must include 'table' and a 'data' object." },
|
|
57
|
-
{ status: 400 }
|
|
58
|
-
)
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
const inserted = await service.insertRow(table, data)
|
|
62
|
-
return NextResponse.json({ data: inserted })
|
|
63
|
-
} catch (error) {
|
|
64
|
-
return toErrorResponse(error, "Failed to insert row")
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
export async function PATCH(request: NextRequest) {
|
|
69
|
-
try {
|
|
70
|
-
// Initialize the singleton to ensure the adapter is registered with the admin service
|
|
71
|
-
getHazoConnectSingleton()
|
|
72
|
-
const service = getSqliteAdminService()
|
|
73
|
-
const payload = await request.json()
|
|
74
|
-
const table = payload?.table
|
|
75
|
-
const data = payload?.data
|
|
76
|
-
const criteria = payload?.criteria
|
|
77
|
-
|
|
78
|
-
if (
|
|
79
|
-
!table ||
|
|
80
|
-
typeof data !== "object" ||
|
|
81
|
-
Array.isArray(data) ||
|
|
82
|
-
typeof criteria !== "object" ||
|
|
83
|
-
criteria === null ||
|
|
84
|
-
Array.isArray(criteria)
|
|
85
|
-
) {
|
|
86
|
-
return NextResponse.json(
|
|
87
|
-
{
|
|
88
|
-
error:
|
|
89
|
-
"Request body must include 'table', 'data' object, and a 'criteria' object for the rows to update."
|
|
90
|
-
},
|
|
91
|
-
{ status: 400 }
|
|
92
|
-
)
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
const rows = await service.updateRows(table, criteria, data)
|
|
96
|
-
return NextResponse.json({ data: rows, updated: rows.length })
|
|
97
|
-
} catch (error) {
|
|
98
|
-
return toErrorResponse(error, "Failed to update rows")
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
export async function DELETE(request: NextRequest) {
|
|
103
|
-
try {
|
|
104
|
-
// Initialize the singleton to ensure the adapter is registered with the admin service
|
|
105
|
-
getHazoConnectSingleton()
|
|
106
|
-
const service = getSqliteAdminService()
|
|
107
|
-
const payload = await request.json()
|
|
108
|
-
const table = payload?.table
|
|
109
|
-
const criteria = payload?.criteria
|
|
110
|
-
|
|
111
|
-
if (
|
|
112
|
-
!table ||
|
|
113
|
-
typeof criteria !== "object" ||
|
|
114
|
-
criteria === null ||
|
|
115
|
-
Array.isArray(criteria)
|
|
116
|
-
) {
|
|
117
|
-
return NextResponse.json(
|
|
118
|
-
{
|
|
119
|
-
error:
|
|
120
|
-
"Request body must include 'table' and a 'criteria' object for the rows to delete."
|
|
121
|
-
},
|
|
122
|
-
{ status: 400 }
|
|
123
|
-
)
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
const rows = await service.deleteRows(table, criteria)
|
|
127
|
-
return NextResponse.json({ data: rows, deleted: rows.length })
|
|
128
|
-
} catch (error) {
|
|
129
|
-
return toErrorResponse(error, "Failed to delete rows")
|
|
130
|
-
}
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
function parseRowQueryOptions(params: URLSearchParams): RowQueryOptions {
|
|
134
|
-
const limitParam = params.get("limit")
|
|
135
|
-
const offsetParam = params.get("offset")
|
|
136
|
-
const orderBy = params.get("orderBy") ?? undefined
|
|
137
|
-
const orderDirection = parseOrderDirection(params.get("orderDirection"))
|
|
138
|
-
const filters = parseFilters(params)
|
|
139
|
-
|
|
140
|
-
const limit = limitParam ? Number.parseInt(limitParam, 10) : undefined
|
|
141
|
-
const offset = offsetParam ? Number.parseInt(offsetParam, 10) : undefined
|
|
142
|
-
|
|
143
|
-
return {
|
|
144
|
-
limit: Number.isNaN(limit) ? undefined : limit,
|
|
145
|
-
offset: Number.isNaN(offset) ? undefined : offset,
|
|
146
|
-
order_by: orderBy ?? undefined,
|
|
147
|
-
order_direction: orderDirection,
|
|
148
|
-
filters: filters.length ? filters : undefined
|
|
149
|
-
}
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
function parseFilters(params: URLSearchParams): SqliteWhereFilter[] {
|
|
153
|
-
const filters: SqliteWhereFilter[] = []
|
|
154
|
-
|
|
155
|
-
params.forEach((value, key) => {
|
|
156
|
-
const match = key.match(/^filter\[(.+?)\](?:\[(.+)\])?$/)
|
|
157
|
-
if (!match) {
|
|
158
|
-
return
|
|
159
|
-
}
|
|
160
|
-
const column = match[1]
|
|
161
|
-
const operatorValue = (match[2] ?? "eq").toLowerCase()
|
|
162
|
-
if (!isAllowedOperator(operatorValue)) {
|
|
163
|
-
throw new Error(`Unsupported filter operator '${operatorValue}'`)
|
|
164
|
-
}
|
|
165
|
-
filters.push({
|
|
166
|
-
column,
|
|
167
|
-
operator: operatorValue as SqliteFilterOperator,
|
|
168
|
-
value
|
|
169
|
-
})
|
|
170
|
-
})
|
|
171
|
-
|
|
172
|
-
return filters
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
function parseOrderDirection(
|
|
176
|
-
direction: string | null
|
|
177
|
-
): "asc" | "desc" | undefined {
|
|
178
|
-
if (!direction) {
|
|
179
|
-
return undefined
|
|
180
|
-
}
|
|
181
|
-
const normalized = direction.toLowerCase()
|
|
182
|
-
if (normalized === "asc" || normalized === "desc") {
|
|
183
|
-
return normalized
|
|
184
|
-
}
|
|
185
|
-
throw new Error(`Unsupported order direction '${direction}'`)
|
|
186
|
-
}
|
|
187
|
-
|
|
188
|
-
function isAllowedOperator(value: string): value is SqliteFilterOperator {
|
|
189
|
-
return allowedOperators.includes(value as SqliteFilterOperator)
|
|
190
|
-
}
|
|
191
|
-
|
|
192
|
-
function toErrorResponse(error: unknown, fallback: string) {
|
|
193
|
-
const message = error instanceof Error ? error.message : fallback
|
|
194
|
-
const status = message.toLowerCase().includes("required") ? 400 : 500
|
|
195
|
-
return NextResponse.json({ error: message }, { status })
|
|
196
|
-
}
|
|
197
|
-
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import { NextRequest, NextResponse } from "next/server"
|
|
2
|
-
import { getSqliteAdminService } from "hazo_connect/server"
|
|
3
|
-
import { getHazoConnectSingleton } from "hazo_connect/nextjs/setup"
|
|
4
|
-
|
|
5
|
-
export const dynamic = "force-dynamic"
|
|
6
|
-
|
|
7
|
-
export async function GET(request: NextRequest) {
|
|
8
|
-
// Initialize the singleton to ensure the adapter is registered with the admin service
|
|
9
|
-
getHazoConnectSingleton()
|
|
10
|
-
const service = getSqliteAdminService()
|
|
11
|
-
const url = new URL(request.url)
|
|
12
|
-
const table = url.searchParams.get("table")
|
|
13
|
-
|
|
14
|
-
if (!table) {
|
|
15
|
-
return NextResponse.json(
|
|
16
|
-
{ error: "Query parameter 'table' is required." },
|
|
17
|
-
{ status: 400 }
|
|
18
|
-
)
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
try {
|
|
22
|
-
const schema = await service.getTableSchema(table)
|
|
23
|
-
return NextResponse.json({ data: schema })
|
|
24
|
-
} catch (error) {
|
|
25
|
-
return toErrorResponse(error, `Failed to load schema for table '${table}'`)
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
function toErrorResponse(error: unknown, fallback: string) {
|
|
30
|
-
const message = error instanceof Error ? error.message : fallback
|
|
31
|
-
const status = message.toLowerCase().includes("required") ? 400 : 500
|
|
32
|
-
return NextResponse.json({ error: message }, { status })
|
|
33
|
-
}
|
|
34
|
-
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import { NextResponse } from "next/server"
|
|
2
|
-
import { getSqliteAdminService } from "hazo_connect/server"
|
|
3
|
-
import { getHazoConnectSingleton } from "hazo_connect/nextjs/setup"
|
|
4
|
-
|
|
5
|
-
export const dynamic = "force-dynamic"
|
|
6
|
-
|
|
7
|
-
export async function GET() {
|
|
8
|
-
try {
|
|
9
|
-
// Initialize the singleton to ensure the adapter is registered with the admin service
|
|
10
|
-
getHazoConnectSingleton()
|
|
11
|
-
|
|
12
|
-
const service = getSqliteAdminService()
|
|
13
|
-
const tables = await service.listTables()
|
|
14
|
-
return NextResponse.json({ data: tables })
|
|
15
|
-
} catch (error) {
|
|
16
|
-
return toErrorResponse(error, "Failed to list SQLite tables")
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
function toErrorResponse(error: unknown, fallback: string) {
|
|
21
|
-
const message = error instanceof Error ? error.message : fallback
|
|
22
|
-
const status = message.toLowerCase().includes("required") ? 400 : 500
|
|
23
|
-
return NextResponse.json({ error: message }, { status })
|
|
24
|
-
}
|
|
25
|
-
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Purpose: Middleware to check if SQLite admin UI is enabled before allowing access to routes.
|
|
3
|
-
*
|
|
4
|
-
* This middleware ensures that the admin UI routes are only accessible when explicitly enabled
|
|
5
|
-
* in the hazo_connect configuration.
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
import { NextResponse } from "next/server"
|
|
9
|
-
import type { NextRequest } from "next/server"
|
|
10
|
-
|
|
11
|
-
export function middleware(request: NextRequest) {
|
|
12
|
-
// Check if this is an admin UI route
|
|
13
|
-
if (
|
|
14
|
-
request.nextUrl.pathname.startsWith("/hazo_connect/sqlite_admin") ||
|
|
15
|
-
request.nextUrl.pathname.startsWith("/hazo_connect/api/sqlite")
|
|
16
|
-
) {
|
|
17
|
-
// Check if admin UI is enabled via environment variable or config
|
|
18
|
-
// The admin service will throw an error if not enabled, but we can provide a better message here
|
|
19
|
-
const adminUiEnabled =
|
|
20
|
-
process.env.HAZO_CONNECT_ENABLE_ADMIN_UI === "true" ||
|
|
21
|
-
process.env.ENABLE_SQLITE_ADMIN_UI === "true"
|
|
22
|
-
|
|
23
|
-
if (!adminUiEnabled) {
|
|
24
|
-
return NextResponse.json(
|
|
25
|
-
{
|
|
26
|
-
error:
|
|
27
|
-
"SQLite admin UI is not enabled. Set 'enable_admin_ui: true' in your hazo_connect configuration or set HAZO_CONNECT_ENABLE_ADMIN_UI=true environment variable."
|
|
28
|
-
},
|
|
29
|
-
{ status: 403 }
|
|
30
|
-
)
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
return NextResponse.next()
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
export const config = {
|
|
38
|
-
matcher: ["/hazo_connect/sqlite_admin/:path*", "/hazo_connect/api/sqlite/:path*"]
|
|
39
|
-
}
|
|
40
|
-
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import { getSqliteAdminService } from "hazo_connect/server"
|
|
2
|
-
import { getHazoConnectSingleton } from "hazo_connect/nextjs/setup"
|
|
3
|
-
import { SqliteAdminClient } from "hazo_connect/ui"
|
|
4
|
-
|
|
5
|
-
export const dynamic = "force-dynamic"
|
|
6
|
-
|
|
7
|
-
export default async function SqliteAdminPage() {
|
|
8
|
-
// Initialize the singleton to ensure the adapter is registered with the admin service
|
|
9
|
-
getHazoConnectSingleton()
|
|
10
|
-
const service = getSqliteAdminService()
|
|
11
|
-
|
|
12
|
-
try {
|
|
13
|
-
const tables = await service.listTables()
|
|
14
|
-
return <SqliteAdminClient initialTables={tables} />
|
|
15
|
-
} catch (error) {
|
|
16
|
-
const message =
|
|
17
|
-
error instanceof Error ? error.message : "Failed to initialise SQLite admin UI."
|
|
18
|
-
|
|
19
|
-
return (
|
|
20
|
-
<section className="mx-auto flex max-w-4xl flex-col gap-4 p-6">
|
|
21
|
-
<h1 className="text-2xl font-semibold text-slate-900">SQLite Admin</h1>
|
|
22
|
-
<p className="rounded-md border border-red-200 bg-red-50 p-4 text-sm text-red-700">
|
|
23
|
-
{message}
|
|
24
|
-
</p>
|
|
25
|
-
</section>
|
|
26
|
-
)
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
|