@bakery-framework/plugin-db-explorer 2.4.2 → 2.5.0-alpha.1
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/package.json +4 -4
- package/src/client/api.ts +0 -5
- package/src/client/grid.ts +1 -1
- package/src/client.ts +1 -1
- package/src/endpoints/rows.ts +3 -8
- package/src/identity.ts +5 -2
- package/src/preview.ts +1 -1
- package/src/setup.ts +6 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bakery-framework/plugin-db-explorer",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.5.0-alpha.1",
|
|
4
4
|
"description": "Bakery database explorer plugin: browse and edit rows, no raw SQL, no DDL.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"bakery",
|
|
@@ -33,10 +33,10 @@
|
|
|
33
33
|
"!src/tests"
|
|
34
34
|
],
|
|
35
35
|
"dependencies": {
|
|
36
|
-
"@bakery-framework/core": "^2.
|
|
37
|
-
"@bakery-framework/orm": "^2.
|
|
36
|
+
"@bakery-framework/core": "^2.5.0-alpha.1",
|
|
37
|
+
"@bakery-framework/orm": "^2.5.0-alpha.1"
|
|
38
38
|
},
|
|
39
39
|
"engines": {
|
|
40
|
-
"bun": ">=1.4.
|
|
40
|
+
"bun": ">=1.4.4"
|
|
41
41
|
}
|
|
42
42
|
}
|
package/src/client/api.ts
CHANGED
|
@@ -184,11 +184,6 @@ function listingSignature(
|
|
|
184
184
|
return JSON.stringify([view.table, view.sortBy ?? '', view.sortOrder, wire])
|
|
185
185
|
}
|
|
186
186
|
|
|
187
|
-
/** Test seam (convention 9): page 2 of one test must not see page 1 of another. */
|
|
188
|
-
export function __resetPageCount(): void {
|
|
189
|
-
lastCounted = null
|
|
190
|
-
}
|
|
191
|
-
|
|
192
187
|
export async function fetchPage(view: ViewState): Promise<Timed<TablePage>> {
|
|
193
188
|
const params: Record<string, string> = {
|
|
194
189
|
tableName: view.table,
|
package/src/client/grid.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* The editable grid: which node holds which value, and where focus is.
|
|
3
3
|
*
|
|
4
|
-
* Two rules keep this file's functions under
|
|
4
|
+
* Two rules keep this file's functions under a cognitive complexity of 25, and
|
|
5
5
|
* they are worth stating because the old `renderTable` broke both and scored
|
|
6
6
|
* 34 with a fraction of the behavior:
|
|
7
7
|
*
|
package/src/client.ts
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
*
|
|
4
4
|
* This file used to be the whole client: 197 lines, one `renderTable` that
|
|
5
5
|
* fetched, built a header, built a body and built a pager, and scored **34**
|
|
6
|
-
* against
|
|
6
|
+
* against Biome's old ceiling of 25. Growing that into a data editor would have
|
|
7
7
|
* meant growing that one function, so the shape changed first. The pieces live
|
|
8
8
|
* under `client/`, each obeying two mechanical rules (**no function both
|
|
9
9
|
* fetches and renders**, and **every loop body is a named function**), and what
|
package/src/endpoints/rows.ts
CHANGED
|
@@ -32,13 +32,7 @@ import {
|
|
|
32
32
|
validateKey,
|
|
33
33
|
validatePartial,
|
|
34
34
|
} from '../validate'
|
|
35
|
-
import {
|
|
36
|
-
beginWrite,
|
|
37
|
-
byName,
|
|
38
|
-
type Envelope,
|
|
39
|
-
invalid,
|
|
40
|
-
refuse,
|
|
41
|
-
} from './common'
|
|
35
|
+
import { beginWrite, byName, type Envelope, invalid, refuse } from './common'
|
|
42
36
|
|
|
43
37
|
/**
|
|
44
38
|
* A conflict, as the caller sees it: which edit, which row, and what the row
|
|
@@ -410,7 +404,8 @@ async function applyCollapsedGroup(
|
|
|
410
404
|
continue
|
|
411
405
|
}
|
|
412
406
|
|
|
413
|
-
let statement = byName
|
|
407
|
+
let statement = byName
|
|
408
|
+
.update(table.name)
|
|
414
409
|
.set(group.set)
|
|
415
410
|
.where(group.column, DB.inList(chunk.map(m => m.value)))
|
|
416
411
|
for (const [column, value] of Object.entries(group.expect)) {
|
package/src/identity.ts
CHANGED
|
@@ -181,7 +181,9 @@ export function describeIdentity(table: TableIntrospection): Identity {
|
|
|
181
181
|
})),
|
|
182
182
|
}))
|
|
183
183
|
.filter(
|
|
184
|
-
(
|
|
184
|
+
(
|
|
185
|
+
index,
|
|
186
|
+
): index is { name: string; cols: { camel: string; raw: string }[] } =>
|
|
185
187
|
index.cols.length > 0 &&
|
|
186
188
|
index.cols.every(
|
|
187
189
|
col =>
|
|
@@ -305,7 +307,8 @@ export function metaOf(
|
|
|
305
307
|
// A column genuinely declared `DEFAULT NULL` reads as having none here. It
|
|
306
308
|
// loses nothing: such a column is nullable, and `nullable` is the next term
|
|
307
309
|
// in that same expression.
|
|
308
|
-
hasDefault:
|
|
310
|
+
hasDefault:
|
|
311
|
+
constraint?.default !== null && constraint?.default !== undefined,
|
|
309
312
|
primary: constraint?.primary ?? schemaColumn.pk,
|
|
310
313
|
autoIncrement: constraint?.autoIncrement,
|
|
311
314
|
}
|
package/src/preview.ts
CHANGED
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
*
|
|
25
25
|
* `status` because two different outcomes need the same mechanism: a dry run
|
|
26
26
|
* answers 200 with what *would* have happened, and a bulk edit that hit an
|
|
27
|
-
*
|
|
27
|
+
* optimistic-concurrency conflict answers 409 with what did, and both have to
|
|
28
28
|
* leave the database untouched, so both have to leave through a throw.
|
|
29
29
|
*/
|
|
30
30
|
export class RollbackSignal<T = unknown> extends Error {
|
package/src/setup.ts
CHANGED
|
@@ -6,7 +6,12 @@ import type { PluginRouteTable } from '@bakery-framework/core/plugins'
|
|
|
6
6
|
import { routeTable } from '@bakery-framework/core/plugins'
|
|
7
7
|
import { fs } from '@bakery-framework/core/utils'
|
|
8
8
|
import { response } from '@bakery-framework/core/utils/http'
|
|
9
|
-
import {
|
|
9
|
+
import {
|
|
10
|
+
accessStore,
|
|
11
|
+
assertValidUsers,
|
|
12
|
+
resolveAccess,
|
|
13
|
+
type AccessConfig,
|
|
14
|
+
} from './access'
|
|
10
15
|
import { handleGraph, handleLookup } from './endpoints/graph'
|
|
11
16
|
import { handleImport } from './endpoints/import'
|
|
12
17
|
import { handleSchema, handleTableData } from './endpoints/read'
|