admindb 1.2.1 → 2.1.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/README.md +262 -329
- package/dist/app.d.ts +25 -4
- package/dist/app.js +79 -15
- package/dist/app.js.map +1 -1
- package/dist/auth/config.d.ts +19 -0
- package/dist/auth/config.js +147 -0
- package/dist/auth/config.js.map +1 -0
- package/dist/auth/crypto.d.ts +27 -0
- package/dist/auth/crypto.js +133 -0
- package/dist/auth/crypto.js.map +1 -0
- package/dist/auth/index.d.ts +5 -0
- package/dist/auth/index.js +22 -0
- package/dist/auth/index.js.map +1 -0
- package/dist/auth/middleware.d.ts +14 -0
- package/dist/auth/middleware.js +100 -0
- package/dist/auth/middleware.js.map +1 -0
- package/dist/auth/routes.d.ts +7 -0
- package/dist/auth/routes.js +78 -0
- package/dist/auth/routes.js.map +1 -0
- package/dist/auth/types.d.ts +35 -0
- package/dist/auth/types.js +11 -0
- package/dist/auth/types.js.map +1 -0
- package/dist/cli/args.d.ts +45 -0
- package/dist/cli/args.js +328 -0
- package/dist/cli/args.js.map +1 -0
- package/dist/cli/config.d.ts +56 -0
- package/dist/cli/config.js +133 -0
- package/dist/cli/config.js.map +1 -0
- package/dist/cli/index.d.ts +4 -0
- package/dist/cli/index.js +21 -0
- package/dist/cli/index.js.map +1 -0
- package/dist/cli/runner.d.ts +1 -0
- package/dist/cli/runner.js +222 -0
- package/dist/cli/runner.js.map +1 -0
- package/dist/cli.js +2 -127
- package/dist/cli.js.map +1 -1
- package/dist/data/datasets.d.ts +17 -0
- package/dist/data/datasets.js +133 -0
- package/dist/data/datasets.js.map +1 -0
- package/dist/data/detector.d.ts +30 -0
- package/dist/data/detector.js +472 -0
- package/dist/data/detector.js.map +1 -0
- package/dist/data/engine.d.ts +10 -0
- package/dist/data/engine.js +211 -0
- package/dist/data/engine.js.map +1 -0
- package/dist/data/index.d.ts +5 -0
- package/dist/data/index.js +22 -0
- package/dist/data/index.js.map +1 -0
- package/dist/data/strategies.d.ts +30 -0
- package/dist/data/strategies.js +343 -0
- package/dist/data/strategies.js.map +1 -0
- package/dist/data/types.d.ts +73 -0
- package/dist/data/types.js +8 -0
- package/dist/data/types.js.map +1 -0
- package/dist/db/database.d.ts +14 -146
- package/dist/db/database.js +208 -461
- package/dist/db/database.js.map +1 -1
- package/dist/db/export.d.ts +2 -2
- package/dist/db/export.js +7 -2
- package/dist/db/export.js.map +1 -1
- package/dist/db/filters.d.ts +22 -0
- package/dist/db/filters.js +158 -0
- package/dist/db/filters.js.map +1 -0
- package/dist/db/index.d.ts +8 -0
- package/dist/db/index.js +25 -0
- package/dist/db/index.js.map +1 -0
- package/dist/db/introspection.d.ts +6 -0
- package/dist/db/introspection.js +172 -0
- package/dist/db/introspection.js.map +1 -0
- package/dist/db/manager.d.ts +32 -19
- package/dist/db/manager.js +203 -44
- package/dist/db/manager.js.map +1 -1
- package/dist/db/migrations.d.ts +5 -0
- package/dist/db/migrations.js +110 -0
- package/dist/db/migrations.js.map +1 -0
- package/dist/db/postgres.d.ts +85 -0
- package/dist/db/postgres.js +745 -0
- package/dist/db/postgres.js.map +1 -0
- package/dist/db/types.d.ts +206 -0
- package/dist/db/types.js +7 -0
- package/dist/db/types.js.map +1 -0
- package/dist/index.d.ts +9 -2
- package/dist/index.js +46 -4
- package/dist/index.js.map +1 -1
- package/dist/public/css/app.css +1 -1
- package/dist/public/css/input.css +74 -11
- package/dist/public/js/app.js +142 -0
- package/dist/public/js/browse.js +591 -104
- package/dist/public/js/databases.js +105 -13
- package/dist/public/js/designer.js +55 -2
- package/dist/public/js/forms.js +610 -28
- package/dist/public/js/icons.js +51 -0
- package/dist/public/js/inspector.js +638 -0
- package/dist/public/js/query.js +93 -3
- package/dist/public/js/schema.js +185 -52
- package/dist/public/js/seed.js +865 -152
- package/dist/routes/api/helpers.d.ts +42 -0
- package/dist/routes/api/helpers.js +133 -0
- package/dist/routes/api/helpers.js.map +1 -0
- package/dist/routes/api/import-export.d.ts +3 -0
- package/dist/routes/api/import-export.js +85 -0
- package/dist/routes/api/import-export.js.map +1 -0
- package/dist/routes/api/index.d.ts +4 -0
- package/dist/routes/api/index.js +37 -0
- package/dist/routes/api/index.js.map +1 -0
- package/dist/routes/api/query.d.ts +3 -0
- package/dist/routes/api/query.js +76 -0
- package/dist/routes/api/query.js.map +1 -0
- package/dist/routes/api/rows.d.ts +3 -0
- package/dist/routes/api/rows.js +373 -0
- package/dist/routes/api/rows.js.map +1 -0
- package/dist/routes/api/seed.d.ts +3 -0
- package/dist/routes/api/seed.js +82 -0
- package/dist/routes/api/seed.js.map +1 -0
- package/dist/routes/api/tables.d.ts +3 -0
- package/dist/routes/api/tables.js +160 -0
- package/dist/routes/api/tables.js.map +1 -0
- package/dist/routes/databases.d.ts +8 -11
- package/dist/routes/databases.js +100 -66
- package/dist/routes/databases.js.map +1 -1
- package/dist/routes/index.d.ts +3 -0
- package/dist/routes/index.js +20 -0
- package/dist/routes/index.js.map +1 -0
- package/dist/routes/pages.d.ts +3 -3
- package/dist/routes/pages.js +157 -64
- package/dist/routes/pages.js.map +1 -1
- package/dist/serverless.d.ts +40 -0
- package/dist/serverless.js +210 -0
- package/dist/serverless.js.map +1 -0
- package/dist/sql/generator.d.ts +7 -3
- package/dist/sql/generator.js +144 -7
- package/dist/sql/generator.js.map +1 -1
- package/dist/sql/index.d.ts +2 -0
- package/dist/sql/index.js +19 -0
- package/dist/sql/index.js.map +1 -0
- package/dist/types/api.d.ts +412 -0
- package/dist/types/api.js +9 -0
- package/dist/types/api.js.map +1 -0
- package/dist/utils/colors.d.ts +40 -0
- package/dist/utils/colors.js +64 -0
- package/dist/utils/colors.js.map +1 -0
- package/dist/{util.d.ts → utils/common.d.ts} +10 -6
- package/dist/{util.js → utils/common.js} +80 -13
- package/dist/utils/common.js.map +1 -0
- package/dist/utils/csv.js.map +1 -0
- package/dist/utils/datatype.d.ts +49 -0
- package/dist/utils/datatype.js +222 -0
- package/dist/utils/datatype.js.map +1 -0
- package/dist/utils/icons.d.ts +11 -0
- package/dist/utils/icons.js +72 -0
- package/dist/utils/icons.js.map +1 -0
- package/dist/utils/index.d.ts +4 -0
- package/dist/utils/index.js +21 -0
- package/dist/utils/index.js.map +1 -0
- package/dist/{logger.d.ts → utils/logger.d.ts} +1 -1
- package/dist/utils/logger.js +40 -0
- package/dist/utils/logger.js.map +1 -0
- package/dist/views/layouts/main.hbs +40 -11
- package/dist/views/pages/databases.hbs +182 -74
- package/dist/views/pages/designer.hbs +29 -11
- package/dist/views/pages/error.hbs +3 -3
- package/dist/views/pages/form.hbs +5 -3
- package/dist/views/pages/home.hbs +22 -13
- package/dist/views/pages/login.hbs +111 -0
- package/dist/views/pages/query.hbs +8 -6
- package/dist/views/pages/schema.hbs +41 -13
- package/dist/views/pages/seed.hbs +200 -54
- package/dist/views/pages/table.hbs +152 -72
- package/dist/views/partials/icon.hbs +2 -0
- package/dist/views/partials/navbar.hbs +69 -25
- package/dist/views/partials/sidebar.hbs +108 -94
- package/docs/API.md +144 -0
- package/docs/EXAMPLES.md +576 -0
- package/docs/SECURITY.md +265 -0
- package/package.json +15 -4
- package/dist/args.d.ts +0 -28
- package/dist/args.js +0 -187
- package/dist/args.js.map +0 -1
- package/dist/config.d.ts +0 -17
- package/dist/config.js +0 -23
- package/dist/config.js.map +0 -1
- package/dist/csv.js.map +0 -1
- package/dist/data/generator.d.ts +0 -86
- package/dist/data/generator.js +0 -1031
- package/dist/data/generator.js.map +0 -1
- package/dist/logger.js +0 -25
- package/dist/logger.js.map +0 -1
- package/dist/routes/api.d.ts +0 -9
- package/dist/routes/api.js +0 -848
- package/dist/routes/api.js.map +0 -1
- package/dist/test/classifier.test.d.ts +0 -1
- package/dist/test/classifier.test.js +0 -44
- package/dist/test/classifier.test.js.map +0 -1
- package/dist/test/csv.test.d.ts +0 -1
- package/dist/test/csv.test.js +0 -64
- package/dist/test/csv.test.js.map +0 -1
- package/dist/test/database.test.d.ts +0 -1
- package/dist/test/database.test.js +0 -402
- package/dist/test/database.test.js.map +0 -1
- package/dist/test/generator.test.d.ts +0 -1
- package/dist/test/generator.test.js +0 -132
- package/dist/test/generator.test.js.map +0 -1
- package/dist/test/manager.test.d.ts +0 -1
- package/dist/test/manager.test.js +0 -146
- package/dist/test/manager.test.js.map +0 -1
- package/dist/util.js.map +0 -1
- /package/dist/{csv.d.ts → utils/csv.d.ts} +0 -0
- /package/dist/{csv.js → utils/csv.js} +0 -0
|
@@ -0,0 +1,412 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* AdminDB — Strongly typed API request and response interfaces.
|
|
3
|
+
*
|
|
4
|
+
* Every REST API endpoint returns a standardized envelope:
|
|
5
|
+
* `{ success: true, data: T }` on success, or `{ success: false, error: string }` on failure.
|
|
6
|
+
*/
|
|
7
|
+
import type { ColumnInfo, ForeignKeyInfo, IndexInfo, SavedQuery, SchemaInfo, TableInfoData, TableListItem, WhereClause, RowFilters } from '../db/database';
|
|
8
|
+
import type { DatabaseEntry } from '../db/manager';
|
|
9
|
+
import type { ColumnDef, IndexDef } from '../sql/generator';
|
|
10
|
+
import type { ColumnGeneratorConfig, ColumnPlan, GeneratorStrategyId, StrategyDescriptor, StrategyCategory } from '../data/index';
|
|
11
|
+
export type { ColumnInfo, ForeignKeyInfo, IndexInfo, SavedQuery, SchemaInfo, TableInfoData, TableListItem, WhereClause, RowFilters, ColumnDef, IndexDef, ColumnGeneratorConfig, ColumnPlan, GeneratorStrategyId, StrategyDescriptor, StrategyCategory, };
|
|
12
|
+
/** Successful API response container. */
|
|
13
|
+
export interface ApiSuccessResponse<T = unknown> {
|
|
14
|
+
success: true;
|
|
15
|
+
data: T;
|
|
16
|
+
}
|
|
17
|
+
/** Error API response container. */
|
|
18
|
+
export interface ApiErrorResponse<T = unknown> {
|
|
19
|
+
success: false;
|
|
20
|
+
error: string;
|
|
21
|
+
data?: T;
|
|
22
|
+
}
|
|
23
|
+
/** Discriminated union of all API responses. */
|
|
24
|
+
export type ApiResponse<T = unknown> = ApiSuccessResponse<T> | ApiErrorResponse<T>;
|
|
25
|
+
/** GET /api/tables */
|
|
26
|
+
export type ListTablesResponseData = TableListItem[];
|
|
27
|
+
export type ListTablesResponse = ApiResponse<ListTablesResponseData>;
|
|
28
|
+
/** GET /api/tables/:table/info */
|
|
29
|
+
export type TableInfoResponseData = TableInfoData;
|
|
30
|
+
export type TableInfoResponse = ApiResponse<TableInfoResponseData>;
|
|
31
|
+
/** GET /api/tables/:table/fk-options */
|
|
32
|
+
export type FkOptionsResponseData = Record<string, {
|
|
33
|
+
value: unknown;
|
|
34
|
+
label: string;
|
|
35
|
+
}[]>;
|
|
36
|
+
export type FkOptionsResponse = ApiResponse<FkOptionsResponseData>;
|
|
37
|
+
/** GET /api/tables/:table/rows */
|
|
38
|
+
export interface GetRowsResponseData {
|
|
39
|
+
rows: Record<string, unknown>[];
|
|
40
|
+
count: number;
|
|
41
|
+
page: number;
|
|
42
|
+
limit: number;
|
|
43
|
+
filters: RowFilters;
|
|
44
|
+
}
|
|
45
|
+
export type GetRowsResponse = ApiResponse<GetRowsResponseData>;
|
|
46
|
+
/** GET /api/tables/:table/row/:id */
|
|
47
|
+
export type GetRowResponseData = Record<string, unknown>;
|
|
48
|
+
export type GetRowResponse = ApiResponse<GetRowResponseData>;
|
|
49
|
+
/** GET /api/tables/:table/rows/:id/references */
|
|
50
|
+
export interface RowReferenceGroup {
|
|
51
|
+
table: string;
|
|
52
|
+
from: string;
|
|
53
|
+
to: string;
|
|
54
|
+
value: unknown;
|
|
55
|
+
count: number;
|
|
56
|
+
columns: string[];
|
|
57
|
+
rows: Record<string, unknown>[];
|
|
58
|
+
}
|
|
59
|
+
export interface GetRowReferencesResponseData {
|
|
60
|
+
references: RowReferenceGroup[];
|
|
61
|
+
}
|
|
62
|
+
export type GetRowReferencesResponse = ApiResponse<GetRowReferencesResponseData>;
|
|
63
|
+
/** POST /api/tables/:table/rows */
|
|
64
|
+
export interface InsertRowRequestBody {
|
|
65
|
+
values: Record<string, unknown>;
|
|
66
|
+
}
|
|
67
|
+
export interface InsertRowResponseData {
|
|
68
|
+
message: string;
|
|
69
|
+
rowId?: number | bigint;
|
|
70
|
+
sql: string;
|
|
71
|
+
}
|
|
72
|
+
export type InsertRowResponse = ApiResponse<InsertRowResponseData>;
|
|
73
|
+
/** POST /api/tables/:table/rows/generate */
|
|
74
|
+
export interface GenerateInsertRequestBody {
|
|
75
|
+
values: Record<string, unknown>;
|
|
76
|
+
}
|
|
77
|
+
export interface GenerateInsertResponseData {
|
|
78
|
+
sql: string;
|
|
79
|
+
}
|
|
80
|
+
export type GenerateInsertResponse = ApiResponse<GenerateInsertResponseData>;
|
|
81
|
+
/** POST /api/tables/:table/rows/import */
|
|
82
|
+
export interface ImportCsvRequestBody {
|
|
83
|
+
csv: string;
|
|
84
|
+
}
|
|
85
|
+
export interface ImportCsvResponseData {
|
|
86
|
+
message: string;
|
|
87
|
+
inserted?: number;
|
|
88
|
+
skipped?: number;
|
|
89
|
+
}
|
|
90
|
+
export type ImportCsvResponse = ApiResponse<ImportCsvResponseData>;
|
|
91
|
+
/** PUT /api/tables/:table/row/:id */
|
|
92
|
+
export interface UpdateRowRequestBody {
|
|
93
|
+
values: Record<string, unknown>;
|
|
94
|
+
nulls?: string[];
|
|
95
|
+
}
|
|
96
|
+
export interface UpdateRowResponseData {
|
|
97
|
+
message: string;
|
|
98
|
+
sql: string;
|
|
99
|
+
}
|
|
100
|
+
export type UpdateRowResponse = ApiResponse<UpdateRowResponseData>;
|
|
101
|
+
/** PUT /api/tables/:table/row/:id/generate */
|
|
102
|
+
export interface GenerateUpdateRequestBody {
|
|
103
|
+
values: Record<string, unknown>;
|
|
104
|
+
nulls?: string[];
|
|
105
|
+
}
|
|
106
|
+
export interface GenerateUpdateResponseData {
|
|
107
|
+
sql: string;
|
|
108
|
+
}
|
|
109
|
+
export type GenerateUpdateResponse = ApiResponse<GenerateUpdateResponseData>;
|
|
110
|
+
/** DELETE /api/tables/:table/row/:id */
|
|
111
|
+
export interface DeleteRowResponseData {
|
|
112
|
+
message: string;
|
|
113
|
+
}
|
|
114
|
+
export type DeleteRowResponse = ApiResponse<DeleteRowResponseData>;
|
|
115
|
+
/** GET /api/tables/:table/row/:id/blob/:column/meta */
|
|
116
|
+
export interface BlobMetaResponseData {
|
|
117
|
+
isNull: boolean;
|
|
118
|
+
mime?: string;
|
|
119
|
+
ext?: string;
|
|
120
|
+
isImage?: boolean;
|
|
121
|
+
isText?: boolean;
|
|
122
|
+
isPdf?: boolean;
|
|
123
|
+
isAudio?: boolean;
|
|
124
|
+
isVideo?: boolean;
|
|
125
|
+
size: number;
|
|
126
|
+
sizeFormatted: string;
|
|
127
|
+
hexDump?: {
|
|
128
|
+
lines: {
|
|
129
|
+
offset: string;
|
|
130
|
+
hex: string;
|
|
131
|
+
ascii: string;
|
|
132
|
+
}[];
|
|
133
|
+
totalBytes: number;
|
|
134
|
+
truncated: boolean;
|
|
135
|
+
};
|
|
136
|
+
textPreview?: string | null;
|
|
137
|
+
}
|
|
138
|
+
export type BlobMetaResponse = ApiResponse<BlobMetaResponseData>;
|
|
139
|
+
/** PUT /api/tables/:table/row/:id/blob/:column */
|
|
140
|
+
export interface UpdateBlobRequestBody {
|
|
141
|
+
data: string;
|
|
142
|
+
format?: 'base64' | 'hex' | 'text';
|
|
143
|
+
}
|
|
144
|
+
export interface UpdateBlobResponseData {
|
|
145
|
+
message: string;
|
|
146
|
+
size: number;
|
|
147
|
+
}
|
|
148
|
+
export type UpdateBlobResponse = ApiResponse<UpdateBlobResponseData>;
|
|
149
|
+
/** GET /api/tables/:table/ddl */
|
|
150
|
+
export interface TableDdlResponseData {
|
|
151
|
+
table: string;
|
|
152
|
+
ddl: string;
|
|
153
|
+
}
|
|
154
|
+
export type TableDdlResponse = ApiResponse<TableDdlResponseData>;
|
|
155
|
+
/** POST /api/tables/:table/rows/bulk-impact */
|
|
156
|
+
export interface BulkImpactRequestBody {
|
|
157
|
+
ids: (string | number)[];
|
|
158
|
+
}
|
|
159
|
+
export interface BulkImpactReference {
|
|
160
|
+
table: string;
|
|
161
|
+
from: string;
|
|
162
|
+
to: string;
|
|
163
|
+
count: number;
|
|
164
|
+
}
|
|
165
|
+
export interface BulkImpactResponseData {
|
|
166
|
+
selected: number;
|
|
167
|
+
references: BulkImpactReference[];
|
|
168
|
+
total: number;
|
|
169
|
+
}
|
|
170
|
+
export type BulkImpactResponse = ApiResponse<BulkImpactResponseData>;
|
|
171
|
+
/** POST /api/tables/:table/rows/bulk-delete */
|
|
172
|
+
export interface BulkDeleteRequestBody {
|
|
173
|
+
ids: (string | number)[];
|
|
174
|
+
confirmImpact?: boolean;
|
|
175
|
+
}
|
|
176
|
+
export interface BulkDeleteResponseData {
|
|
177
|
+
message: string;
|
|
178
|
+
deleted: number;
|
|
179
|
+
}
|
|
180
|
+
export type BulkDeleteResponse = ApiResponse<BulkDeleteResponseData>;
|
|
181
|
+
/** POST /api/tables/:table/rows/bulk-export */
|
|
182
|
+
export interface BulkExportRequestBody {
|
|
183
|
+
ids: (string | number)[];
|
|
184
|
+
format?: 'csv' | 'json';
|
|
185
|
+
}
|
|
186
|
+
export interface BulkExportResponseData {
|
|
187
|
+
format: string;
|
|
188
|
+
filename: string;
|
|
189
|
+
content: string;
|
|
190
|
+
rowCount: number;
|
|
191
|
+
}
|
|
192
|
+
export type BulkExportResponse = ApiResponse<BulkExportResponseData>;
|
|
193
|
+
/** POST /api/tables/:table/rows/bulk-update */
|
|
194
|
+
export interface BulkUpdateItem {
|
|
195
|
+
id: string | number;
|
|
196
|
+
values?: Record<string, unknown>;
|
|
197
|
+
nulls?: string[];
|
|
198
|
+
}
|
|
199
|
+
export interface BulkUpdateRequestBody {
|
|
200
|
+
updates: BulkUpdateItem[];
|
|
201
|
+
}
|
|
202
|
+
export interface BulkUpdateResponseData {
|
|
203
|
+
message: string;
|
|
204
|
+
updated: number;
|
|
205
|
+
}
|
|
206
|
+
export type BulkUpdateResponse = ApiResponse<BulkUpdateResponseData>;
|
|
207
|
+
/** GET /api/tables/:table/seed/config */
|
|
208
|
+
export interface SeedConfigResponseData {
|
|
209
|
+
table: string;
|
|
210
|
+
columns: ColumnGeneratorConfig[];
|
|
211
|
+
maxRows: number;
|
|
212
|
+
}
|
|
213
|
+
export type SeedConfigResponse = ApiResponse<SeedConfigResponseData>;
|
|
214
|
+
/** POST /api/tables/:table/seed/generate */
|
|
215
|
+
export interface SeedGenerateRequestBody {
|
|
216
|
+
count?: number;
|
|
217
|
+
plan?: Record<string, ColumnPlan>;
|
|
218
|
+
}
|
|
219
|
+
export interface SeedGenerateResponseData {
|
|
220
|
+
table: string;
|
|
221
|
+
count: number;
|
|
222
|
+
sql: string;
|
|
223
|
+
previewRows?: Record<string, unknown>[];
|
|
224
|
+
warnings: string[];
|
|
225
|
+
}
|
|
226
|
+
export type SeedGenerateResponse = ApiResponse<SeedGenerateResponseData>;
|
|
227
|
+
/** POST /api/tables/:table/seed */
|
|
228
|
+
export interface SeedInsertRequestBody {
|
|
229
|
+
count?: number;
|
|
230
|
+
plan?: Record<string, ColumnPlan>;
|
|
231
|
+
truncate?: boolean;
|
|
232
|
+
}
|
|
233
|
+
export interface SeedInsertResponseData {
|
|
234
|
+
message: string;
|
|
235
|
+
inserted: number;
|
|
236
|
+
skipped: number;
|
|
237
|
+
warnings: string[];
|
|
238
|
+
elapsedMs?: number;
|
|
239
|
+
}
|
|
240
|
+
export type SeedInsertResponse = ApiResponse<SeedInsertResponseData>;
|
|
241
|
+
/** POST /api/tables */
|
|
242
|
+
export interface CreateTableRequestBody {
|
|
243
|
+
name: string;
|
|
244
|
+
columns: ColumnDef[];
|
|
245
|
+
}
|
|
246
|
+
export interface CreateTableResponseData {
|
|
247
|
+
message: string;
|
|
248
|
+
sql: string;
|
|
249
|
+
}
|
|
250
|
+
export type CreateTableResponse = ApiResponse<CreateTableResponseData>;
|
|
251
|
+
/** POST /api/tables/generate */
|
|
252
|
+
export interface GenerateCreateTableRequestBody {
|
|
253
|
+
name: string;
|
|
254
|
+
columns: ColumnDef[];
|
|
255
|
+
}
|
|
256
|
+
export interface GenerateCreateTableResponseData {
|
|
257
|
+
sql: string;
|
|
258
|
+
}
|
|
259
|
+
export type GenerateCreateTableResponse = ApiResponse<GenerateCreateTableResponseData>;
|
|
260
|
+
/** GET /api/tables/:table/schema */
|
|
261
|
+
export type GetSchemaResponseData = SchemaInfo;
|
|
262
|
+
export type GetSchemaResponse = ApiResponse<GetSchemaResponseData>;
|
|
263
|
+
/** POST /api/tables/:table/rename */
|
|
264
|
+
export interface RenameTableRequestBody {
|
|
265
|
+
name: string;
|
|
266
|
+
}
|
|
267
|
+
export interface RenameTableResponseData {
|
|
268
|
+
message: string;
|
|
269
|
+
sql: string;
|
|
270
|
+
table: string;
|
|
271
|
+
}
|
|
272
|
+
export type RenameTableResponse = ApiResponse<RenameTableResponseData>;
|
|
273
|
+
/** POST /api/tables/:table/columns */
|
|
274
|
+
export interface AddColumnRequestBody {
|
|
275
|
+
column: ColumnDef;
|
|
276
|
+
}
|
|
277
|
+
export interface AddColumnResponseData {
|
|
278
|
+
message: string;
|
|
279
|
+
sql: string;
|
|
280
|
+
}
|
|
281
|
+
export type AddColumnResponse = ApiResponse<AddColumnResponseData>;
|
|
282
|
+
/** PUT /api/tables/:table/columns/:column */
|
|
283
|
+
export interface RenameColumnRequestBody {
|
|
284
|
+
name: string;
|
|
285
|
+
}
|
|
286
|
+
export interface RenameColumnResponseData {
|
|
287
|
+
message: string;
|
|
288
|
+
sql: string;
|
|
289
|
+
}
|
|
290
|
+
export type RenameColumnResponse = ApiResponse<RenameColumnResponseData>;
|
|
291
|
+
/** DELETE /api/tables/:table/columns/:column */
|
|
292
|
+
export interface DropColumnResponseData {
|
|
293
|
+
message: string;
|
|
294
|
+
sql: string;
|
|
295
|
+
}
|
|
296
|
+
export type DropColumnResponse = ApiResponse<DropColumnResponseData>;
|
|
297
|
+
/** DELETE /api/tables/:table */
|
|
298
|
+
export interface DropTableResponseData {
|
|
299
|
+
message: string;
|
|
300
|
+
sql: string;
|
|
301
|
+
}
|
|
302
|
+
export type DropTableResponse = ApiResponse<DropTableResponseData>;
|
|
303
|
+
/** POST /api/tables/:table/indexes */
|
|
304
|
+
export interface CreateIndexRequestBody {
|
|
305
|
+
name?: string;
|
|
306
|
+
columns: string[];
|
|
307
|
+
unique?: boolean;
|
|
308
|
+
}
|
|
309
|
+
export interface CreateIndexResponseData {
|
|
310
|
+
message: string;
|
|
311
|
+
sql: string;
|
|
312
|
+
}
|
|
313
|
+
export type CreateIndexResponse = ApiResponse<CreateIndexResponseData>;
|
|
314
|
+
/** DELETE /api/tables/:table/indexes/:index */
|
|
315
|
+
export interface DropIndexResponseData {
|
|
316
|
+
message: string;
|
|
317
|
+
sql: string;
|
|
318
|
+
}
|
|
319
|
+
export type DropIndexResponse = ApiResponse<DropIndexResponseData>;
|
|
320
|
+
/** POST /api/query request */
|
|
321
|
+
export interface ExecuteQueryRequestBody {
|
|
322
|
+
sql: string;
|
|
323
|
+
}
|
|
324
|
+
/** Result when SQL is classified as COUNT */
|
|
325
|
+
export interface QueryCountResult {
|
|
326
|
+
kind: 'count';
|
|
327
|
+
count: number;
|
|
328
|
+
message: string;
|
|
329
|
+
}
|
|
330
|
+
/** Result when SQL is classified as SELECT / READ */
|
|
331
|
+
export interface QuerySelectResult {
|
|
332
|
+
kind: 'select';
|
|
333
|
+
columns: string[];
|
|
334
|
+
rows: Record<string, unknown>[];
|
|
335
|
+
}
|
|
336
|
+
/** Result when SQL is a write statement (INSERT, UPDATE, DELETE, DDL, Script) */
|
|
337
|
+
export interface QueryWriteResult {
|
|
338
|
+
kind: 'write';
|
|
339
|
+
changes: number | null;
|
|
340
|
+
message: string;
|
|
341
|
+
}
|
|
342
|
+
/** Discriminated union of all query results */
|
|
343
|
+
export type ExecuteQueryResponseData = QueryCountResult | QuerySelectResult | QueryWriteResult;
|
|
344
|
+
export type ExecuteQueryResponse = ApiResponse<ExecuteQueryResponseData>;
|
|
345
|
+
/** POST /api/query/export */
|
|
346
|
+
export interface ExportQueryRequestBody {
|
|
347
|
+
sql: string;
|
|
348
|
+
format?: 'csv' | 'json';
|
|
349
|
+
}
|
|
350
|
+
/** GET /api/queries */
|
|
351
|
+
export type ListSavedQueriesResponseData = SavedQuery[];
|
|
352
|
+
export type ListSavedQueriesResponse = ApiResponse<ListSavedQueriesResponseData>;
|
|
353
|
+
/** POST /api/queries */
|
|
354
|
+
export interface SaveQueryRequestBody {
|
|
355
|
+
name: string;
|
|
356
|
+
sql: string;
|
|
357
|
+
}
|
|
358
|
+
export interface SaveQueryResponseData {
|
|
359
|
+
message: string;
|
|
360
|
+
}
|
|
361
|
+
export type SaveQueryResponse = ApiResponse<SaveQueryResponseData>;
|
|
362
|
+
/** DELETE /api/queries/:id */
|
|
363
|
+
export interface DeleteSavedQueryResponseData {
|
|
364
|
+
message: string;
|
|
365
|
+
}
|
|
366
|
+
export type DeleteSavedQueryResponse = ApiResponse<DeleteSavedQueryResponseData>;
|
|
367
|
+
export interface DatabaseRow extends DatabaseEntry {
|
|
368
|
+
sizeLabel: string;
|
|
369
|
+
modifiedLabel: string;
|
|
370
|
+
tables: number;
|
|
371
|
+
}
|
|
372
|
+
/** GET /api/databases */
|
|
373
|
+
export type ListDatabasesResponseData = DatabaseRow[];
|
|
374
|
+
export type ListDatabasesResponse = ApiResponse<ListDatabasesResponseData>;
|
|
375
|
+
/** POST /api/databases */
|
|
376
|
+
export interface CreateDatabaseRequestBody {
|
|
377
|
+
name: string;
|
|
378
|
+
}
|
|
379
|
+
export interface CreateDatabaseResponseData {
|
|
380
|
+
id: string;
|
|
381
|
+
message: string;
|
|
382
|
+
}
|
|
383
|
+
export type CreateDatabaseResponse = ApiResponse<CreateDatabaseResponseData>;
|
|
384
|
+
/** POST /api/databases/open */
|
|
385
|
+
export interface OpenDatabaseRequestBody {
|
|
386
|
+
path: string;
|
|
387
|
+
}
|
|
388
|
+
export interface OpenDatabaseResponseData {
|
|
389
|
+
id: string;
|
|
390
|
+
message: string;
|
|
391
|
+
}
|
|
392
|
+
export type OpenDatabaseResponse = ApiResponse<OpenDatabaseResponseData>;
|
|
393
|
+
/** DELETE /api/databases/:id */
|
|
394
|
+
export interface DeleteDatabaseResponseData {
|
|
395
|
+
message: string;
|
|
396
|
+
}
|
|
397
|
+
export type DeleteDatabaseResponse = ApiResponse<DeleteDatabaseResponseData>;
|
|
398
|
+
export interface FsEntry {
|
|
399
|
+
name: string;
|
|
400
|
+
path: string;
|
|
401
|
+
isDir: boolean;
|
|
402
|
+
isDb: boolean;
|
|
403
|
+
size: number;
|
|
404
|
+
}
|
|
405
|
+
/** GET /api/fs/list */
|
|
406
|
+
export interface ListFsResponseData {
|
|
407
|
+
path: string;
|
|
408
|
+
name: string;
|
|
409
|
+
parent: string | null;
|
|
410
|
+
entries: FsEntry[];
|
|
411
|
+
}
|
|
412
|
+
export type ListFsResponse = ApiResponse<ListFsResponseData>;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* AdminDB — Strongly typed API request and response interfaces.
|
|
4
|
+
*
|
|
5
|
+
* Every REST API endpoint returns a standardized envelope:
|
|
6
|
+
* `{ success: true, data: T }` on success, or `{ success: false, error: string }` on failure.
|
|
7
|
+
*/
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
//# sourceMappingURL=api.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"api.js","sourceRoot":"","sources":["../../src/types/api.ts"],"names":[],"mappings":";AAAA;;;;;GAKG"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Lightweight ANSI color utility with zero runtime dependencies.
|
|
3
|
+
*
|
|
4
|
+
* Supports detection of terminal color capabilities via `process.stdout.isTTY`,
|
|
5
|
+
* `FORCE_COLOR`, `NO_COLOR`, and CI environments.
|
|
6
|
+
*/
|
|
7
|
+
export declare function supportsColor(): boolean;
|
|
8
|
+
export declare const c: {
|
|
9
|
+
reset: (str: unknown) => string;
|
|
10
|
+
bold: (str: unknown) => string;
|
|
11
|
+
dim: (str: unknown) => string;
|
|
12
|
+
italic: (str: unknown) => string;
|
|
13
|
+
underline: (str: unknown) => string;
|
|
14
|
+
inverse: (str: unknown) => string;
|
|
15
|
+
black: (str: unknown) => string;
|
|
16
|
+
red: (str: unknown) => string;
|
|
17
|
+
green: (str: unknown) => string;
|
|
18
|
+
yellow: (str: unknown) => string;
|
|
19
|
+
blue: (str: unknown) => string;
|
|
20
|
+
magenta: (str: unknown) => string;
|
|
21
|
+
cyan: (str: unknown) => string;
|
|
22
|
+
white: (str: unknown) => string;
|
|
23
|
+
gray: (str: unknown) => string;
|
|
24
|
+
brightRed: (str: unknown) => string;
|
|
25
|
+
brightGreen: (str: unknown) => string;
|
|
26
|
+
brightYellow: (str: unknown) => string;
|
|
27
|
+
brightBlue: (str: unknown) => string;
|
|
28
|
+
brightMagenta: (str: unknown) => string;
|
|
29
|
+
brightCyan: (str: unknown) => string;
|
|
30
|
+
brightWhite: (str: unknown) => string;
|
|
31
|
+
bgBlack: (str: unknown) => string;
|
|
32
|
+
bgRed: (str: unknown) => string;
|
|
33
|
+
bgGreen: (str: unknown) => string;
|
|
34
|
+
bgYellow: (str: unknown) => string;
|
|
35
|
+
bgBlue: (str: unknown) => string;
|
|
36
|
+
bgMagenta: (str: unknown) => string;
|
|
37
|
+
bgCyan: (str: unknown) => string;
|
|
38
|
+
bgWhite: (str: unknown) => string;
|
|
39
|
+
bgGray: (str: unknown) => string;
|
|
40
|
+
};
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Lightweight ANSI color utility with zero runtime dependencies.
|
|
4
|
+
*
|
|
5
|
+
* Supports detection of terminal color capabilities via `process.stdout.isTTY`,
|
|
6
|
+
* `FORCE_COLOR`, `NO_COLOR`, and CI environments.
|
|
7
|
+
*/
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.c = void 0;
|
|
10
|
+
exports.supportsColor = supportsColor;
|
|
11
|
+
function supportsColor() {
|
|
12
|
+
if (process.env.NO_COLOR || process.env.NODE_DISABLE_COLORS)
|
|
13
|
+
return false;
|
|
14
|
+
if (process.env.FORCE_COLOR && process.env.FORCE_COLOR !== '0')
|
|
15
|
+
return true;
|
|
16
|
+
if (process.env.TERM === 'dumb')
|
|
17
|
+
return false;
|
|
18
|
+
if (process.env.CI)
|
|
19
|
+
return true;
|
|
20
|
+
return Boolean(process.stdout && process.stdout.isTTY);
|
|
21
|
+
}
|
|
22
|
+
const wrap = (open, close) => (str) => {
|
|
23
|
+
const text = String(str ?? '');
|
|
24
|
+
if (!supportsColor() || !text)
|
|
25
|
+
return text;
|
|
26
|
+
return `${open}${text}${close}`;
|
|
27
|
+
};
|
|
28
|
+
exports.c = {
|
|
29
|
+
reset: wrap('\x1b[0m', '\x1b[0m'),
|
|
30
|
+
bold: wrap('\x1b[1m', '\x1b[22m'),
|
|
31
|
+
dim: wrap('\x1b[2m', '\x1b[22m'),
|
|
32
|
+
italic: wrap('\x1b[3m', '\x1b[23m'),
|
|
33
|
+
underline: wrap('\x1b[4m', '\x1b[24m'),
|
|
34
|
+
inverse: wrap('\x1b[7m', '\x1b[27m'),
|
|
35
|
+
// Foreground colors
|
|
36
|
+
black: wrap('\x1b[30m', '\x1b[39m'),
|
|
37
|
+
red: wrap('\x1b[31m', '\x1b[39m'),
|
|
38
|
+
green: wrap('\x1b[32m', '\x1b[39m'),
|
|
39
|
+
yellow: wrap('\x1b[33m', '\x1b[39m'),
|
|
40
|
+
blue: wrap('\x1b[34m', '\x1b[39m'),
|
|
41
|
+
magenta: wrap('\x1b[35m', '\x1b[39m'),
|
|
42
|
+
cyan: wrap('\x1b[36m', '\x1b[39m'),
|
|
43
|
+
white: wrap('\x1b[37m', '\x1b[39m'),
|
|
44
|
+
gray: wrap('\x1b[90m', '\x1b[39m'),
|
|
45
|
+
// Bright foregrounds
|
|
46
|
+
brightRed: wrap('\x1b[91m', '\x1b[39m'),
|
|
47
|
+
brightGreen: wrap('\x1b[92m', '\x1b[39m'),
|
|
48
|
+
brightYellow: wrap('\x1b[93m', '\x1b[39m'),
|
|
49
|
+
brightBlue: wrap('\x1b[94m', '\x1b[39m'),
|
|
50
|
+
brightMagenta: wrap('\x1b[95m', '\x1b[39m'),
|
|
51
|
+
brightCyan: wrap('\x1b[96m', '\x1b[39m'),
|
|
52
|
+
brightWhite: wrap('\x1b[97m', '\x1b[39m'),
|
|
53
|
+
// Background colors
|
|
54
|
+
bgBlack: wrap('\x1b[40m', '\x1b[49m'),
|
|
55
|
+
bgRed: wrap('\x1b[41m', '\x1b[49m'),
|
|
56
|
+
bgGreen: wrap('\x1b[42m', '\x1b[49m'),
|
|
57
|
+
bgYellow: wrap('\x1b[43m', '\x1b[49m'),
|
|
58
|
+
bgBlue: wrap('\x1b[44m', '\x1b[49m'),
|
|
59
|
+
bgMagenta: wrap('\x1b[45m', '\x1b[49m'),
|
|
60
|
+
bgCyan: wrap('\x1b[46m', '\x1b[49m'),
|
|
61
|
+
bgWhite: wrap('\x1b[47m', '\x1b[49m'),
|
|
62
|
+
bgGray: wrap('\x1b[100m', '\x1b[49m'),
|
|
63
|
+
};
|
|
64
|
+
//# sourceMappingURL=colors.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"colors.js","sourceRoot":"","sources":["../../src/utils/colors.ts"],"names":[],"mappings":"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"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
/** Small shared helpers used across the server. */
|
|
2
1
|
export declare function errorMessage(err: unknown): string;
|
|
3
2
|
/**
|
|
4
3
|
* True when `p` is equal to `root` or lives inside it (both treated as
|
|
5
4
|
* absolute). Used to sandbox the filesystem file-browser to an allowed folder.
|
|
5
|
+
* Resolves symlinks and rejects null-byte injections.
|
|
6
6
|
*/
|
|
7
7
|
export declare function isPathWithinRoot(root: string, p: string): boolean;
|
|
8
8
|
/** Operators understood by the structured (type-aware) filter conditions. */
|
|
@@ -36,11 +36,15 @@ export declare function normalizeCell(value: unknown): unknown;
|
|
|
36
36
|
/** Normalize every cell in a row. */
|
|
37
37
|
export declare function normalizeRow(row: Record<string, unknown>): Record<string, unknown>;
|
|
38
38
|
/**
|
|
39
|
-
* Coerce a raw form value into a value suitable for SQLite binding.
|
|
39
|
+
* Coerce a raw form value into a value suitable for SQLite or Postgres binding.
|
|
40
40
|
* - empty string / null / undefined → null ("not set")
|
|
41
41
|
* - `0` stays valid
|
|
42
|
-
* - BOOLEAN → 1/0
|
|
43
|
-
* - INTEGER/REAL → number when numeric
|
|
44
|
-
* - BLOB → Buffer (0x-hex or raw text)
|
|
42
|
+
* - BOOLEAN → 1/0 (SQLite) or boolean (PostgreSQL)
|
|
43
|
+
* - INTEGER/REAL/BIGINT/NUMERIC → number when numeric
|
|
44
|
+
* - BLOB / BYTEA → Buffer (0x-hex, \x-hex, or raw text)
|
|
45
45
|
*/
|
|
46
|
-
export declare function coerceFormValue(raw: unknown, columnType: string): unknown;
|
|
46
|
+
export declare function coerceFormValue(raw: unknown, columnType: string, dialect?: 'sqlite' | 'postgres'): unknown;
|
|
47
|
+
/** Format byte size to human readable string (e.g. 1.2 MB). */
|
|
48
|
+
export declare function formatBytes(bytes: number): string;
|
|
49
|
+
/** Truncate a string with an ellipsis if it exceeds maxLength. */
|
|
50
|
+
export declare function truncate(str: string, maxLength: number): string;
|