admindb 2.1.0 → 2.2.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/README.md +41 -12
- package/dist/app.d.ts +1 -69
- package/dist/app.js +3 -30
- package/dist/auth/config.d.ts +1 -19
- package/dist/auth/config.js +0 -26
- package/dist/auth/crypto.d.ts +1 -27
- package/dist/auth/crypto.js +1 -26
- package/dist/auth/index.d.ts +1 -5
- package/dist/auth/index.js +0 -1
- package/dist/auth/middleware.d.ts +1 -14
- package/dist/auth/middleware.js +0 -15
- package/dist/auth/routes.d.ts +1 -7
- package/dist/auth/routes.js +0 -8
- package/dist/auth/types.d.ts +1 -35
- package/dist/auth/types.js +1 -5
- package/dist/cli/args.d.ts +1 -45
- package/dist/cli/args.js +3 -11
- package/dist/cli/config.d.ts +1 -56
- package/dist/cli/config.js +0 -5
- package/dist/cli/index.d.ts +1 -4
- package/dist/cli/index.js +0 -1
- package/dist/cli/runner.d.ts +1 -1
- package/dist/cli/runner.js +6 -17
- package/dist/cli.d.ts +1 -2
- package/dist/cli.js +0 -1
- package/dist/data/chain.d.ts +1 -0
- package/dist/data/chain.js +707 -0
- package/dist/data/datasets.d.ts +1 -17
- package/dist/data/datasets.js +0 -4
- package/dist/data/detector.d.ts +1 -30
- package/dist/data/detector.js +53 -14
- package/dist/data/engine.d.ts +1 -10
- package/dist/data/engine.js +82 -48
- package/dist/data/index.d.ts +1 -5
- package/dist/data/index.js +1 -1
- package/dist/data/strategies.d.ts +1 -30
- package/dist/data/strategies.js +4 -8
- package/dist/data/types.d.ts +1 -73
- package/dist/data/types.js +0 -3
- package/dist/db/database.d.ts +1 -119
- package/dist/db/database.js +20 -14
- package/dist/db/export.d.ts +1 -12
- package/dist/db/export.js +54 -6
- package/dist/db/filters.d.ts +1 -22
- package/dist/db/filters.js +0 -16
- package/dist/db/index.d.ts +1 -8
- package/dist/db/index.js +0 -1
- package/dist/db/introspection.d.ts +1 -6
- package/dist/db/introspection.js +0 -5
- package/dist/db/manager.d.ts +1 -81
- package/dist/db/manager.js +13 -59
- package/dist/db/migrations.d.ts +1 -5
- package/dist/db/migrations.js +2 -5
- package/dist/db/postgres.d.ts +1 -85
- package/dist/db/postgres.js +21 -31
- package/dist/db/types.d.ts +1 -206
- package/dist/db/types.js +0 -1
- package/dist/index.d.ts +1 -23
- package/dist/index.js +0 -14
- package/dist/public/css/app.css +1 -1
- package/dist/public/js/api.js +1 -47
- package/dist/public/js/app.js +1 -262
- package/dist/public/js/browse.js +1 -1371
- package/dist/public/js/common.js +1 -0
- package/dist/public/js/databases.js +1 -235
- package/dist/public/js/designer.js +1 -258
- package/dist/public/js/forms.js +1 -826
- package/dist/public/js/home.js +1 -0
- package/dist/public/js/inspector.js +1 -638
- package/dist/public/js/query.js +1 -322
- package/dist/public/js/schema.js +1 -447
- package/dist/public/js/seed.js +1 -1090
- package/dist/routes/api/erd.d.ts +1 -0
- package/dist/routes/api/erd.js +50 -0
- package/dist/routes/api/helpers.d.ts +1 -42
- package/dist/routes/api/helpers.js +33 -3
- package/dist/routes/api/import-export.d.ts +1 -3
- package/dist/routes/api/import-export.js +0 -2
- package/dist/routes/api/index.d.ts +1 -4
- package/dist/routes/api/index.js +15 -4
- package/dist/routes/api/query.d.ts +1 -3
- package/dist/routes/api/query.js +13 -11
- package/dist/routes/api/rows.d.ts +1 -3
- package/dist/routes/api/rows.js +0 -11
- package/dist/routes/api/seed.d.ts +1 -3
- package/dist/routes/api/seed.js +79 -8
- package/dist/routes/api/tables.d.ts +1 -3
- package/dist/routes/api/tables.js +77 -6
- package/dist/routes/databases.d.ts +1 -26
- package/dist/routes/databases.js +1 -3
- package/dist/routes/index.d.ts +1 -3
- package/dist/routes/index.js +0 -1
- package/dist/routes/pages.d.ts +1 -9
- package/dist/routes/pages.js +18 -11
- package/dist/serverless.d.ts +1 -40
- package/dist/serverless.js +3 -39
- package/dist/sql/classifier.d.ts +1 -19
- package/dist/sql/classifier.js +0 -13
- package/dist/sql/error-analyzer.d.ts +1 -0
- package/dist/sql/error-analyzer.js +550 -0
- package/dist/sql/generator.d.ts +1 -81
- package/dist/sql/generator.js +0 -29
- package/dist/sql/index.d.ts +1 -2
- package/dist/sql/index.js +0 -1
- package/dist/types/api.d.ts +1 -412
- package/dist/types/api.js +0 -7
- package/dist/utils/colors.d.ts +1 -40
- package/dist/utils/colors.js +0 -10
- package/dist/utils/common.d.ts +1 -50
- package/dist/utils/common.js +19 -23
- package/dist/utils/csv.d.ts +1 -15
- package/dist/utils/csv.js +0 -13
- package/dist/utils/datatype.d.ts +1 -49
- package/dist/utils/datatype.js +0 -41
- package/dist/utils/icons.d.ts +1 -11
- package/dist/utils/icons.js +25 -16
- package/dist/utils/index.d.ts +1 -4
- package/dist/utils/index.js +0 -1
- package/dist/utils/logger.d.ts +1 -10
- package/dist/utils/logger.js +0 -4
- package/dist/views/layouts/main.hbs +14 -5
- package/dist/views/pages/databases.hbs +0 -18
- package/dist/views/pages/designer.hbs +0 -10
- package/dist/views/pages/erd.hbs +1241 -0
- package/dist/views/pages/error.hbs +0 -2
- package/dist/views/pages/form.hbs +0 -5
- package/dist/views/pages/home.hbs +98 -10
- package/dist/views/pages/info.hbs +107 -0
- package/dist/views/pages/login.hbs +0 -13
- package/dist/views/pages/query.hbs +54 -21
- package/dist/views/pages/schema.hbs +0 -20
- package/dist/views/pages/seed.hbs +435 -202
- package/dist/views/pages/table.hbs +0 -14
- package/dist/views/partials/icon.hbs +0 -1
- package/dist/views/partials/navbar.hbs +0 -6
- package/dist/views/partials/sidebar.hbs +12 -8
- package/docs/API.md +6 -1
- package/docs/EXAMPLES.md +3 -0
- package/package.json +7 -5
- package/dist/app.js.map +0 -1
- package/dist/auth/config.js.map +0 -1
- package/dist/auth/crypto.js.map +0 -1
- package/dist/auth/index.js.map +0 -1
- package/dist/auth/middleware.js.map +0 -1
- package/dist/auth/routes.js.map +0 -1
- package/dist/auth/types.js.map +0 -1
- package/dist/cli/args.js.map +0 -1
- package/dist/cli/config.js.map +0 -1
- package/dist/cli/index.js.map +0 -1
- package/dist/cli/runner.js.map +0 -1
- package/dist/cli.js.map +0 -1
- package/dist/data/datasets.js.map +0 -1
- package/dist/data/detector.js.map +0 -1
- package/dist/data/engine.js.map +0 -1
- package/dist/data/index.js.map +0 -1
- package/dist/data/strategies.js.map +0 -1
- package/dist/data/types.js.map +0 -1
- package/dist/db/database.js.map +0 -1
- package/dist/db/export.js.map +0 -1
- package/dist/db/filters.js.map +0 -1
- package/dist/db/index.js.map +0 -1
- package/dist/db/introspection.js.map +0 -1
- package/dist/db/manager.js.map +0 -1
- package/dist/db/migrations.js.map +0 -1
- package/dist/db/postgres.js.map +0 -1
- package/dist/db/types.js.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/public/css/input.css +0 -302
- package/dist/public/js/icons.js +0 -51
- package/dist/routes/api/helpers.js.map +0 -1
- package/dist/routes/api/import-export.js.map +0 -1
- package/dist/routes/api/index.js.map +0 -1
- package/dist/routes/api/query.js.map +0 -1
- package/dist/routes/api/rows.js.map +0 -1
- package/dist/routes/api/seed.js.map +0 -1
- package/dist/routes/api/tables.js.map +0 -1
- package/dist/routes/databases.js.map +0 -1
- package/dist/routes/index.js.map +0 -1
- package/dist/routes/pages.js.map +0 -1
- package/dist/serverless.js.map +0 -1
- package/dist/sql/classifier.js.map +0 -1
- package/dist/sql/generator.js.map +0 -1
- package/dist/sql/index.js.map +0 -1
- package/dist/types/api.js.map +0 -1
- package/dist/utils/colors.js.map +0 -1
- package/dist/utils/common.js.map +0 -1
- package/dist/utils/csv.js.map +0 -1
- package/dist/utils/datatype.js.map +0 -1
- package/dist/utils/icons.js.map +0 -1
- package/dist/utils/index.js.map +0 -1
- package/dist/utils/logger.js.map +0 -1
package/dist/utils/common.d.ts
CHANGED
|
@@ -1,50 +1 @@
|
|
|
1
|
-
export declare function errorMessage(err: unknown): string;
|
|
2
|
-
/**
|
|
3
|
-
* True when `p` is equal to `root` or lives inside it (both treated as
|
|
4
|
-
* absolute). Used to sandbox the filesystem file-browser to an allowed folder.
|
|
5
|
-
* Resolves symlinks and rejects null-byte injections.
|
|
6
|
-
*/
|
|
7
|
-
export declare function isPathWithinRoot(root: string, p: string): boolean;
|
|
8
|
-
/** Operators understood by the structured (type-aware) filter conditions. */
|
|
9
|
-
export type FilterOp = 'eq' | 'neq' | 'gt' | 'gte' | 'lt' | 'lte' | 'like' | 'prefix' | 'between' | 'null' | 'notnull';
|
|
10
|
-
/** A single structured filter condition produced by the type-aware filter form. */
|
|
11
|
-
export interface FilterCondition {
|
|
12
|
-
op: FilterOp;
|
|
13
|
-
/** Primary operand for scalar operators; lower bound for `between`. */
|
|
14
|
-
value?: string;
|
|
15
|
-
/** Upper bound for `between`. */
|
|
16
|
-
max?: string;
|
|
17
|
-
}
|
|
18
|
-
/** A filter value: the legacy string syntax or one/more structured conditions. */
|
|
19
|
-
export type FilterValue = string | FilterCondition | FilterCondition[];
|
|
20
|
-
/** Row filters keyed by column name. */
|
|
21
|
-
export interface RowFilters {
|
|
22
|
-
[column: string]: FilterValue;
|
|
23
|
-
}
|
|
24
|
-
/** Parse the `f` query parameter (URL-encoded JSON object) into row filters. */
|
|
25
|
-
export declare function parseFilters(raw: unknown): RowFilters;
|
|
26
|
-
/** Encode filters back into a `f=…` query string (empty when no filters). */
|
|
27
|
-
export declare function filtersToQS(filters: RowFilters | undefined): string;
|
|
28
|
-
/** Internal tables (kept out of user-facing pickers) start with an underscore. */
|
|
29
|
-
export declare function isInternalTable(name: string): boolean;
|
|
30
|
-
/** Encode primary-key values into a single URL path segment (comma-joined, URL-encoded). */
|
|
31
|
-
export declare function encodePk(values: unknown[]): string;
|
|
32
|
-
/** Decode a primary-key path segment back into individual values. */
|
|
33
|
-
export declare function decodePk(encoded: string): string[];
|
|
34
|
-
/** Normalize a single cell for JSON / display (BLOB → 0x-hex string, undefined → null). */
|
|
35
|
-
export declare function normalizeCell(value: unknown): unknown;
|
|
36
|
-
/** Normalize every cell in a row. */
|
|
37
|
-
export declare function normalizeRow(row: Record<string, unknown>): Record<string, unknown>;
|
|
38
|
-
/**
|
|
39
|
-
* Coerce a raw form value into a value suitable for SQLite or Postgres binding.
|
|
40
|
-
* - empty string / null / undefined → null ("not set")
|
|
41
|
-
* - `0` stays valid
|
|
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
|
-
*/
|
|
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;
|
|
1
|
+
export declare function errorMessage(err:unknown):string;export declare function isPostgresConnectionString(target:unknown):boolean;export declare function sanitizeConnectionString(conn:string):string;export declare function isPathWithinRoot(root:string,p:string):boolean;export type FilterOp='eq'|'neq'|'gt'|'gte'|'lt'|'lte'|'like'|'prefix'|'between'|'null'|'notnull';export interface FilterCondition{op:FilterOp;value?:string;max?:string;}export type FilterValue=string|FilterCondition|FilterCondition[];export interface RowFilters{[column:string]:FilterValue;}export declare function parseFilters(raw:unknown):RowFilters;export declare function filtersToQS(filters:RowFilters|undefined):string;export declare function isInternalTable(name:string):boolean;export declare function encodePk(values:unknown[]):string;export declare function decodePk(encoded:string):string[];export declare function normalizeCell(value:unknown):unknown;export declare function normalizeRow(row:Record<string,unknown>):Record<string,unknown>;export declare function coerceFormValue(raw:unknown,columnType:string,dialect?:'sqlite'|'postgres'):unknown;export declare function formatBytes(bytes:number):string;export declare function truncate(str:string,maxLength:number):string;
|
package/dist/utils/common.js
CHANGED
|
@@ -4,6 +4,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.errorMessage = errorMessage;
|
|
7
|
+
exports.isPostgresConnectionString = isPostgresConnectionString;
|
|
8
|
+
exports.sanitizeConnectionString = sanitizeConnectionString;
|
|
7
9
|
exports.isPathWithinRoot = isPathWithinRoot;
|
|
8
10
|
exports.parseFilters = parseFilters;
|
|
9
11
|
exports.filtersToQS = filtersToQS;
|
|
@@ -22,11 +24,23 @@ function errorMessage(err) {
|
|
|
22
24
|
return err.message;
|
|
23
25
|
return String(err);
|
|
24
26
|
}
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
27
|
+
function isPostgresConnectionString(target) {
|
|
28
|
+
return (typeof target === 'string' &&
|
|
29
|
+
(target.startsWith('postgres://') || target.startsWith('postgresql://')));
|
|
30
|
+
}
|
|
31
|
+
function sanitizeConnectionString(conn) {
|
|
32
|
+
if (!conn || typeof conn !== 'string')
|
|
33
|
+
return '';
|
|
34
|
+
try {
|
|
35
|
+
const u = new URL(conn);
|
|
36
|
+
if (u.password) {
|
|
37
|
+
u.password = '****';
|
|
38
|
+
return u.toString();
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
catch { }
|
|
42
|
+
return conn.replace(/:([^:@]+)@/, ':****@');
|
|
43
|
+
}
|
|
30
44
|
function isPathWithinRoot(root, p) {
|
|
31
45
|
if (!root || !p || typeof root !== 'string' || typeof p !== 'string')
|
|
32
46
|
return false;
|
|
@@ -49,7 +63,6 @@ function isPathWithinRoot(root, p) {
|
|
|
49
63
|
const rel = node_path_1.default.relative(realRoot, realPath);
|
|
50
64
|
return rel === '' || (!rel.startsWith('..') && !node_path_1.default.isAbsolute(rel));
|
|
51
65
|
}
|
|
52
|
-
/** Parse the `f` query parameter (URL-encoded JSON object) into row filters. */
|
|
53
66
|
function parseFilters(raw) {
|
|
54
67
|
const out = {};
|
|
55
68
|
const add = (obj) => {
|
|
@@ -83,7 +96,6 @@ function parseFilters(raw) {
|
|
|
83
96
|
}
|
|
84
97
|
return out;
|
|
85
98
|
}
|
|
86
|
-
/** Encode filters back into a `f=…` query string (empty when no filters). */
|
|
87
99
|
function filtersToQS(filters) {
|
|
88
100
|
const out = {};
|
|
89
101
|
for (const [k, v] of Object.entries(filters ?? {})) {
|
|
@@ -107,15 +119,12 @@ function filtersToQS(filters) {
|
|
|
107
119
|
return '';
|
|
108
120
|
return 'f=' + encodeURIComponent(JSON.stringify(out));
|
|
109
121
|
}
|
|
110
|
-
/** Internal tables (kept out of user-facing pickers) start with an underscore. */
|
|
111
122
|
function isInternalTable(name) {
|
|
112
123
|
return name.startsWith('_');
|
|
113
124
|
}
|
|
114
|
-
/** Encode primary-key values into a single URL path segment (comma-joined, URL-encoded). */
|
|
115
125
|
function encodePk(values) {
|
|
116
126
|
return values.map((v) => encodeURIComponent(v == null ? '' : String(v))).join(',');
|
|
117
127
|
}
|
|
118
|
-
/** Decode a primary-key path segment back into individual values. */
|
|
119
128
|
function decodePk(encoded) {
|
|
120
129
|
return String(encoded)
|
|
121
130
|
.split(',')
|
|
@@ -128,7 +137,6 @@ function decodePk(encoded) {
|
|
|
128
137
|
}
|
|
129
138
|
});
|
|
130
139
|
}
|
|
131
|
-
/** Normalize a single cell for JSON / display (BLOB → 0x-hex string, undefined → null). */
|
|
132
140
|
function normalizeCell(value) {
|
|
133
141
|
if (value instanceof Uint8Array || Buffer.isBuffer(value)) {
|
|
134
142
|
return `0x${Buffer.from(value).toString('hex')}`;
|
|
@@ -143,21 +151,12 @@ function normalizeCell(value) {
|
|
|
143
151
|
return null;
|
|
144
152
|
return value;
|
|
145
153
|
}
|
|
146
|
-
/** Normalize every cell in a row. */
|
|
147
154
|
function normalizeRow(row) {
|
|
148
155
|
const out = {};
|
|
149
156
|
for (const [k, v] of Object.entries(row ?? {}))
|
|
150
157
|
out[k] = normalizeCell(v);
|
|
151
158
|
return out;
|
|
152
159
|
}
|
|
153
|
-
/**
|
|
154
|
-
* Coerce a raw form value into a value suitable for SQLite or Postgres binding.
|
|
155
|
-
* - empty string / null / undefined → null ("not set")
|
|
156
|
-
* - `0` stays valid
|
|
157
|
-
* - BOOLEAN → 1/0 (SQLite) or boolean (PostgreSQL)
|
|
158
|
-
* - INTEGER/REAL/BIGINT/NUMERIC → number when numeric
|
|
159
|
-
* - BLOB / BYTEA → Buffer (0x-hex, \x-hex, or raw text)
|
|
160
|
-
*/
|
|
161
160
|
function coerceFormValue(raw, columnType, dialect = 'sqlite') {
|
|
162
161
|
const type = (columnType || '').toUpperCase();
|
|
163
162
|
if (raw === undefined || raw === null)
|
|
@@ -211,7 +210,6 @@ function coerceFormValue(raw, columnType, dialect = 'sqlite') {
|
|
|
211
210
|
return null;
|
|
212
211
|
return s;
|
|
213
212
|
}
|
|
214
|
-
/** Format byte size to human readable string (e.g. 1.2 MB). */
|
|
215
213
|
function formatBytes(bytes) {
|
|
216
214
|
if (bytes === 0)
|
|
217
215
|
return '0 B';
|
|
@@ -220,10 +218,8 @@ function formatBytes(bytes) {
|
|
|
220
218
|
const i = Math.floor(Math.log(bytes) / Math.log(k));
|
|
221
219
|
return `${parseFloat((bytes / Math.pow(k, i)).toFixed(1))} ${sizes[i]}`;
|
|
222
220
|
}
|
|
223
|
-
/** Truncate a string with an ellipsis if it exceeds maxLength. */
|
|
224
221
|
function truncate(str, maxLength) {
|
|
225
222
|
if (!str || str.length <= maxLength)
|
|
226
223
|
return str;
|
|
227
224
|
return `${str.slice(0, maxLength)}…`;
|
|
228
225
|
}
|
|
229
|
-
//# sourceMappingURL=common.js.map
|
package/dist/utils/csv.d.ts
CHANGED
|
@@ -1,15 +1 @@
|
|
|
1
|
-
|
|
2
|
-
* Minimal RFC 4180-style CSV serialization and parsing, used for table and
|
|
3
|
-
* query export/import. Pure functions with no I/O so they are easy to test.
|
|
4
|
-
*/
|
|
5
|
-
/** Escape a single CSV field (quote when it contains comma, quote or newline). */
|
|
6
|
-
export declare function csvEscape(value: unknown): string;
|
|
7
|
-
/** Serialize rows to CSV with an explicit column order. */
|
|
8
|
-
export declare function toCsv(rows: Record<string, unknown>[], columns: string[]): string;
|
|
9
|
-
/** Serialize rows to JSON (values are expected to be already normalized). */
|
|
10
|
-
export declare function toJson(rows: Record<string, unknown>[]): string;
|
|
11
|
-
/**
|
|
12
|
-
* Parse CSV text into rows of string fields. Handles quoted fields containing
|
|
13
|
-
* commas, quotes and embedded newlines. Blank lines are skipped.
|
|
14
|
-
*/
|
|
15
|
-
export declare function parseCsv(text: string): string[][];
|
|
1
|
+
export declare function csvEscape(value:unknown):string;export declare function toCsv(rows:Record<string,unknown>[],columns:string[]):string;export declare function toJson(rows:Record<string,unknown>[]):string;export declare function parseCsv(text:string):string[][];
|
package/dist/utils/csv.js
CHANGED
|
@@ -1,34 +1,23 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* Minimal RFC 4180-style CSV serialization and parsing, used for table and
|
|
4
|
-
* query export/import. Pure functions with no I/O so they are easy to test.
|
|
5
|
-
*/
|
|
6
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
3
|
exports.csvEscape = csvEscape;
|
|
8
4
|
exports.toCsv = toCsv;
|
|
9
5
|
exports.toJson = toJson;
|
|
10
6
|
exports.parseCsv = parseCsv;
|
|
11
|
-
/** Escape a single CSV field (quote when it contains comma, quote or newline). */
|
|
12
7
|
function csvEscape(value) {
|
|
13
8
|
const s = value === null || value === undefined ? '' : String(value);
|
|
14
9
|
if (/[",\r\n]/.test(s))
|
|
15
10
|
return `"${s.replace(/"/g, '""')}"`;
|
|
16
11
|
return s;
|
|
17
12
|
}
|
|
18
|
-
/** Serialize rows to CSV with an explicit column order. */
|
|
19
13
|
function toCsv(rows, columns) {
|
|
20
14
|
const header = columns.map(csvEscape).join(',');
|
|
21
15
|
const body = rows.map((row) => columns.map((c) => csvEscape(row[c])).join(','));
|
|
22
16
|
return [header, ...body].join('\r\n');
|
|
23
17
|
}
|
|
24
|
-
/** Serialize rows to JSON (values are expected to be already normalized). */
|
|
25
18
|
function toJson(rows) {
|
|
26
19
|
return JSON.stringify(rows, null, 2);
|
|
27
20
|
}
|
|
28
|
-
/**
|
|
29
|
-
* Parse CSV text into rows of string fields. Handles quoted fields containing
|
|
30
|
-
* commas, quotes and embedded newlines. Blank lines are skipped.
|
|
31
|
-
*/
|
|
32
21
|
function parseCsv(text) {
|
|
33
22
|
const rows = [];
|
|
34
23
|
let row = [];
|
|
@@ -66,7 +55,6 @@ function parseCsv(text) {
|
|
|
66
55
|
row = [];
|
|
67
56
|
}
|
|
68
57
|
else if (ch === '\r') {
|
|
69
|
-
// Ignore — part of CRLF line endings.
|
|
70
58
|
}
|
|
71
59
|
else {
|
|
72
60
|
field += ch;
|
|
@@ -77,4 +65,3 @@ function parseCsv(text) {
|
|
|
77
65
|
rows.push(row);
|
|
78
66
|
return rows;
|
|
79
67
|
}
|
|
80
|
-
//# sourceMappingURL=csv.js.map
|
package/dist/utils/datatype.d.ts
CHANGED
|
@@ -1,49 +1 @@
|
|
|
1
|
-
|
|
2
|
-
* Utilities for rich data type detection, MIME sniffing, hex dump generation,
|
|
3
|
-
* and JSON inspection in AdminDB.
|
|
4
|
-
*/
|
|
5
|
-
export interface MimeAnalysis {
|
|
6
|
-
mime: string;
|
|
7
|
-
ext: string;
|
|
8
|
-
isImage: boolean;
|
|
9
|
-
isText: boolean;
|
|
10
|
-
isPdf: boolean;
|
|
11
|
-
isAudio: boolean;
|
|
12
|
-
isVideo: boolean;
|
|
13
|
-
}
|
|
14
|
-
export interface HexDumpLine {
|
|
15
|
-
offset: string;
|
|
16
|
-
hex: string;
|
|
17
|
-
ascii: string;
|
|
18
|
-
}
|
|
19
|
-
export interface HexDumpResult {
|
|
20
|
-
lines: HexDumpLine[];
|
|
21
|
-
totalBytes: number;
|
|
22
|
-
truncated: boolean;
|
|
23
|
-
}
|
|
24
|
-
export interface BlobMetadata extends MimeAnalysis {
|
|
25
|
-
size: number;
|
|
26
|
-
sizeFormatted: string;
|
|
27
|
-
hexDump?: HexDumpResult;
|
|
28
|
-
textPreview?: string | null;
|
|
29
|
-
}
|
|
30
|
-
/**
|
|
31
|
-
* Sniff MIME type and file extension from magic bytes of a buffer.
|
|
32
|
-
*/
|
|
33
|
-
export declare function sniffMimeType(buf: Uint8Array | Buffer): MimeAnalysis;
|
|
34
|
-
/**
|
|
35
|
-
* Generate formatted 3-column Hex Dump (Offset | Hex Bytes | ASCII).
|
|
36
|
-
*/
|
|
37
|
-
export declare function generateHexDump(buf: Uint8Array | Buffer, maxBytes?: number, bytesPerLine?: number): HexDumpResult;
|
|
38
|
-
/**
|
|
39
|
-
* Get comprehensive metadata for a binary buffer or hex string.
|
|
40
|
-
*/
|
|
41
|
-
export declare function analyzeBlob(data: Uint8Array | Buffer | string): BlobMetadata;
|
|
42
|
-
/**
|
|
43
|
-
* Detect whether a value is a valid JSON string (Object or Array).
|
|
44
|
-
*/
|
|
45
|
-
export declare function isJsonString(value: unknown): boolean;
|
|
46
|
-
/**
|
|
47
|
-
* Parse and pretty format JSON string. Returns null if invalid.
|
|
48
|
-
*/
|
|
49
|
-
export declare function formatJsonSafely(value: unknown, indent?: number): string | null;
|
|
1
|
+
export interface MimeAnalysis{mime:string;ext:string;isImage:boolean;isText:boolean;isPdf:boolean;isAudio:boolean;isVideo:boolean;}export interface HexDumpLine{offset:string;hex:string;ascii:string;}export interface HexDumpResult{lines:HexDumpLine[];totalBytes:number;truncated:boolean;}export interface BlobMetadata extends MimeAnalysis{size:number;sizeFormatted:string;hexDump?:HexDumpResult;textPreview?:string|null;}export declare function sniffMimeType(buf:Uint8Array|Buffer):MimeAnalysis;export declare function generateHexDump(buf:Uint8Array|Buffer,maxBytes?:number,bytesPerLine?:number):HexDumpResult;export declare function analyzeBlob(data:Uint8Array|Buffer|string):BlobMetadata;export declare function isJsonString(value:unknown):boolean;export declare function formatJsonSafely(value:unknown,indent?:number):string|null;
|
package/dist/utils/datatype.js
CHANGED
|
@@ -1,8 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* Utilities for rich data type detection, MIME sniffing, hex dump generation,
|
|
4
|
-
* and JSON inspection in AdminDB.
|
|
5
|
-
*/
|
|
6
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
3
|
exports.sniffMimeType = sniffMimeType;
|
|
8
4
|
exports.generateHexDump = generateHexDump;
|
|
@@ -10,84 +6,64 @@ exports.analyzeBlob = analyzeBlob;
|
|
|
10
6
|
exports.isJsonString = isJsonString;
|
|
11
7
|
exports.formatJsonSafely = formatJsonSafely;
|
|
12
8
|
const common_js_1 = require("./common.js");
|
|
13
|
-
/**
|
|
14
|
-
* Sniff MIME type and file extension from magic bytes of a buffer.
|
|
15
|
-
*/
|
|
16
9
|
function sniffMimeType(buf) {
|
|
17
10
|
const len = buf.length;
|
|
18
11
|
if (len === 0) {
|
|
19
12
|
return { mime: 'application/octet-stream', ext: 'bin', isImage: false, isText: false, isPdf: false, isAudio: false, isVideo: false };
|
|
20
13
|
}
|
|
21
|
-
// PNG: 89 50 4E 47 0D 0A 1A 0A
|
|
22
14
|
if (len >= 8 && buf[0] === 0x89 && buf[1] === 0x50 && buf[2] === 0x4e && buf[3] === 0x47 && buf[4] === 0x0d && buf[5] === 0x0a && buf[6] === 0x1a && buf[7] === 0x0a) {
|
|
23
15
|
return { mime: 'image/png', ext: 'png', isImage: true, isText: false, isPdf: false, isAudio: false, isVideo: false };
|
|
24
16
|
}
|
|
25
|
-
// JPEG: FF D8 FF
|
|
26
17
|
if (len >= 3 && buf[0] === 0xff && buf[1] === 0xd8 && buf[2] === 0xff) {
|
|
27
18
|
return { mime: 'image/jpeg', ext: 'jpg', isImage: true, isText: false, isPdf: false, isAudio: false, isVideo: false };
|
|
28
19
|
}
|
|
29
|
-
// GIF: GIF87a or GIF89a (47 49 46 38 37/39 61)
|
|
30
20
|
if (len >= 6 && buf[0] === 0x47 && buf[1] === 0x49 && buf[2] === 0x46 && buf[3] === 0x38 && (buf[4] === 0x37 || buf[4] === 0x39) && buf[5] === 0x61) {
|
|
31
21
|
return { mime: 'image/gif', ext: 'gif', isImage: true, isText: false, isPdf: false, isAudio: false, isVideo: false };
|
|
32
22
|
}
|
|
33
|
-
// WebP: RIFF....WEBP (52 49 46 46 ... 57 45 42 50)
|
|
34
23
|
if (len >= 12 && buf[0] === 0x52 && buf[1] === 0x49 && buf[2] === 0x46 && buf[3] === 0x46 && buf[8] === 0x57 && buf[9] === 0x45 && buf[10] === 0x42 && buf[11] === 0x50) {
|
|
35
24
|
return { mime: 'image/webp', ext: 'webp', isImage: true, isText: false, isPdf: false, isAudio: false, isVideo: false };
|
|
36
25
|
}
|
|
37
|
-
// BMP: 42 4D
|
|
38
26
|
if (len >= 2 && buf[0] === 0x42 && buf[1] === 0x4d) {
|
|
39
27
|
return { mime: 'image/bmp', ext: 'bmp', isImage: true, isText: false, isPdf: false, isAudio: false, isVideo: false };
|
|
40
28
|
}
|
|
41
|
-
// ICO: 00 00 01 00
|
|
42
29
|
if (len >= 4 && buf[0] === 0x00 && buf[1] === 0x00 && buf[2] === 0x01 && buf[3] === 0x00) {
|
|
43
30
|
return { mime: 'image/x-icon', ext: 'ico', isImage: true, isText: false, isPdf: false, isAudio: false, isVideo: false };
|
|
44
31
|
}
|
|
45
|
-
// PDF: %PDF (25 50 44 46)
|
|
46
32
|
if (len >= 4 && buf[0] === 0x25 && buf[1] === 0x50 && buf[2] === 0x44 && buf[3] === 0x46) {
|
|
47
33
|
return { mime: 'application/pdf', ext: 'pdf', isImage: false, isText: false, isPdf: true, isAudio: false, isVideo: false };
|
|
48
34
|
}
|
|
49
|
-
// MP3: ID3 (49 44 33) or Sync 0xFF 0xFB/0xF3/0xF2
|
|
50
35
|
if (len >= 3 && buf[0] === 0x49 && buf[1] === 0x44 && buf[2] === 0x33) {
|
|
51
36
|
return { mime: 'audio/mpeg', ext: 'mp3', isImage: false, isText: false, isPdf: false, isAudio: true, isVideo: false };
|
|
52
37
|
}
|
|
53
38
|
if (len >= 2 && buf[0] === 0xff && (buf[1] & 0xe0) === 0xe0) {
|
|
54
39
|
return { mime: 'audio/mpeg', ext: 'mp3', isImage: false, isText: false, isPdf: false, isAudio: true, isVideo: false };
|
|
55
40
|
}
|
|
56
|
-
// WAV: RIFF....WAVE
|
|
57
41
|
if (len >= 12 && buf[0] === 0x52 && buf[1] === 0x49 && buf[2] === 0x46 && buf[3] === 0x46 && buf[8] === 0x57 && buf[9] === 0x41 && buf[10] === 0x56 && buf[11] === 0x45) {
|
|
58
42
|
return { mime: 'audio/wav', ext: 'wav', isImage: false, isText: false, isPdf: false, isAudio: true, isVideo: false };
|
|
59
43
|
}
|
|
60
|
-
// OGG: OggS (4F 67 67 53)
|
|
61
44
|
if (len >= 4 && buf[0] === 0x4f && buf[1] === 0x67 && buf[2] === 0x67 && buf[3] === 0x53) {
|
|
62
45
|
return { mime: 'audio/ogg', ext: 'ogg', isImage: false, isText: false, isPdf: false, isAudio: true, isVideo: false };
|
|
63
46
|
}
|
|
64
|
-
// MP4 video: ....ftyp (66 74 79 70)
|
|
65
47
|
if (len >= 8 && buf[4] === 0x66 && buf[5] === 0x74 && buf[6] === 0x79 && buf[7] === 0x70) {
|
|
66
48
|
return { mime: 'video/mp4', ext: 'mp4', isImage: false, isText: false, isPdf: false, isAudio: false, isVideo: true };
|
|
67
49
|
}
|
|
68
|
-
// WebM: 1A 45 DF A3
|
|
69
50
|
if (len >= 4 && buf[0] === 0x1a && buf[1] === 0x45 && buf[2] === 0xdf && buf[3] === 0xa3) {
|
|
70
51
|
return { mime: 'video/webm', ext: 'webm', isImage: false, isText: false, isPdf: false, isAudio: false, isVideo: true };
|
|
71
52
|
}
|
|
72
|
-
// Check for UTF-8 Text / SVG / JSON
|
|
73
53
|
const sampleLen = Math.min(len, 1024);
|
|
74
54
|
const sample = Buffer.from(buf.subarray(0, sampleLen)).toString('utf8');
|
|
75
55
|
const trimmed = sample.trim();
|
|
76
|
-
// SVG: starts with <?xml or <svg
|
|
77
56
|
if (trimmed.startsWith('<svg') || (trimmed.startsWith('<?xml') && trimmed.includes('<svg'))) {
|
|
78
57
|
return { mime: 'image/svg+xml', ext: 'svg', isImage: true, isText: true, isPdf: false, isAudio: false, isVideo: false };
|
|
79
58
|
}
|
|
80
|
-
// JSON
|
|
81
59
|
if ((trimmed.startsWith('{') && trimmed.endsWith('}')) || (trimmed.startsWith('[') && trimmed.endsWith(']'))) {
|
|
82
60
|
try {
|
|
83
61
|
JSON.parse(sample);
|
|
84
62
|
return { mime: 'application/json', ext: 'json', isImage: false, isText: true, isPdf: false, isAudio: false, isVideo: false };
|
|
85
63
|
}
|
|
86
64
|
catch {
|
|
87
|
-
/* not valid json in sample */
|
|
88
65
|
}
|
|
89
66
|
}
|
|
90
|
-
// Check if buffer contains mostly printable ASCII / UTF-8
|
|
91
67
|
let nonPrintable = 0;
|
|
92
68
|
for (let i = 0; i < sampleLen; i++) {
|
|
93
69
|
const byte = buf[i];
|
|
@@ -100,9 +76,6 @@ function sniffMimeType(buf) {
|
|
|
100
76
|
}
|
|
101
77
|
return { mime: 'application/octet-stream', ext: 'bin', isImage: false, isText: false, isPdf: false, isAudio: false, isVideo: false };
|
|
102
78
|
}
|
|
103
|
-
/**
|
|
104
|
-
* Generate formatted 3-column Hex Dump (Offset | Hex Bytes | ASCII).
|
|
105
|
-
*/
|
|
106
79
|
function generateHexDump(buf, maxBytes = 4096, bytesPerLine = 16) {
|
|
107
80
|
const totalBytes = buf.length;
|
|
108
81
|
const limit = Math.min(totalBytes, maxBytes);
|
|
@@ -117,7 +90,6 @@ function generateHexDump(buf, maxBytes = 4096, bytesPerLine = 16) {
|
|
|
117
90
|
if (j < chunk.length) {
|
|
118
91
|
const byte = chunk[j];
|
|
119
92
|
hexParts.push(byte.toString(16).padStart(2, '0'));
|
|
120
|
-
// Printable ASCII between 32 (space) and 126 (~)
|
|
121
93
|
asciiPart += (byte >= 32 && byte <= 126) ? String.fromCharCode(byte) : '.';
|
|
122
94
|
}
|
|
123
95
|
else {
|
|
@@ -125,7 +97,6 @@ function generateHexDump(buf, maxBytes = 4096, bytesPerLine = 16) {
|
|
|
125
97
|
asciiPart += ' ';
|
|
126
98
|
}
|
|
127
99
|
}
|
|
128
|
-
// Insert extra space in the middle for readability (e.g. after 8 bytes)
|
|
129
100
|
const mid = Math.floor(bytesPerLine / 2);
|
|
130
101
|
const hexFormatted = hexParts.slice(0, mid).join(' ') + ' ' + hexParts.slice(mid).join(' ');
|
|
131
102
|
lines.push({
|
|
@@ -136,9 +107,6 @@ function generateHexDump(buf, maxBytes = 4096, bytesPerLine = 16) {
|
|
|
136
107
|
}
|
|
137
108
|
return { lines, totalBytes, truncated };
|
|
138
109
|
}
|
|
139
|
-
/**
|
|
140
|
-
* Get comprehensive metadata for a binary buffer or hex string.
|
|
141
|
-
*/
|
|
142
110
|
function analyzeBlob(data) {
|
|
143
111
|
let buf;
|
|
144
112
|
if (typeof data === 'string') {
|
|
@@ -157,13 +125,11 @@ function analyzeBlob(data) {
|
|
|
157
125
|
if (analysis.isText || buf.length < 2048) {
|
|
158
126
|
try {
|
|
159
127
|
const txt = buf.toString('utf8');
|
|
160
|
-
// If it looks like valid text
|
|
161
128
|
if (!/[\x00-\x08\x0E-\x1F]/.test(txt.slice(0, 512))) {
|
|
162
129
|
textPreview = txt.slice(0, 4000);
|
|
163
130
|
}
|
|
164
131
|
}
|
|
165
132
|
catch {
|
|
166
|
-
/* ignore */
|
|
167
133
|
}
|
|
168
134
|
}
|
|
169
135
|
return {
|
|
@@ -174,9 +140,6 @@ function analyzeBlob(data) {
|
|
|
174
140
|
textPreview,
|
|
175
141
|
};
|
|
176
142
|
}
|
|
177
|
-
/**
|
|
178
|
-
* Detect whether a value is a valid JSON string (Object or Array).
|
|
179
|
-
*/
|
|
180
143
|
function isJsonString(value) {
|
|
181
144
|
if (typeof value !== 'string')
|
|
182
145
|
return false;
|
|
@@ -194,9 +157,6 @@ function isJsonString(value) {
|
|
|
194
157
|
}
|
|
195
158
|
return false;
|
|
196
159
|
}
|
|
197
|
-
/**
|
|
198
|
-
* Parse and pretty format JSON string. Returns null if invalid.
|
|
199
|
-
*/
|
|
200
160
|
function formatJsonSafely(value, indent = 2) {
|
|
201
161
|
if (value === null || value === undefined)
|
|
202
162
|
return null;
|
|
@@ -219,4 +179,3 @@ function formatJsonSafely(value, indent = 2) {
|
|
|
219
179
|
}
|
|
220
180
|
return null;
|
|
221
181
|
}
|
|
222
|
-
//# sourceMappingURL=datatype.js.map
|
package/dist/utils/icons.d.ts
CHANGED
|
@@ -1,11 +1 @@
|
|
|
1
|
-
|
|
2
|
-
* SVG Icons registry for AdminDB.
|
|
3
|
-
*
|
|
4
|
-
* Centralizes all SVG icons in a single module, providing consistent
|
|
5
|
-
* styling, clean templates, and zero inline SVG duplication.
|
|
6
|
-
*/
|
|
7
|
-
export declare const ICONS: Record<string, string>;
|
|
8
|
-
/**
|
|
9
|
-
* Renders an SVG icon by name with optional custom CSS classes.
|
|
10
|
-
*/
|
|
11
|
-
export declare function renderIcon(name: string, customClass?: string): string;
|
|
1
|
+
export declare const ICONS:Record<string,string>;export declare function renderIcon(name:string,customClass?:string):string;
|
package/dist/utils/icons.js
CHANGED
|
@@ -1,15 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* SVG Icons registry for AdminDB.
|
|
4
|
-
*
|
|
5
|
-
* Centralizes all SVG icons in a single module, providing consistent
|
|
6
|
-
* styling, clean templates, and zero inline SVG duplication.
|
|
7
|
-
*/
|
|
8
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
3
|
exports.ICONS = void 0;
|
|
10
4
|
exports.renderIcon = renderIcon;
|
|
11
5
|
exports.ICONS = {
|
|
12
|
-
// Navigation & Core
|
|
13
6
|
menu: '<svg xmlns="http://www.w3.org/2000/svg" class="h-5 w-5" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path stroke-linecap="round" stroke-linejoin="round" d="M4 6h16M4 12h16M4 18h16" /></svg>',
|
|
14
7
|
home: '<svg xmlns="http://www.w3.org/2000/svg" class="h-4 w-4" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path stroke-linecap="round" stroke-linejoin="round" d="M3 12l2-2m0 0l7-7 7 7M5 10v10a1 1 0 001 1h3m10-11l2 2m-2-2v10a1 1 0 01-1 1h-3m-6 0a1 1 0 001-1v-4a1 1 0 011-1h2a1 1 0 011 1v4a1 1 0 001 1m-6 0h6" /></svg>',
|
|
15
8
|
database: '<svg xmlns="http://www.w3.org/2000/svg" class="h-4 w-4" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path stroke-linecap="round" stroke-linejoin="round" d="M4 7v10c0 1.1.9 2 2 2h12a2 2 0 002-2V7M4 7c0-1.1.9-2 2-2h12a2 2 0 012 2M4 7c0 1.1.9 2 2 2h12a2 2 0 002-2" /></svg>',
|
|
@@ -19,7 +12,7 @@ exports.ICONS = {
|
|
|
19
12
|
plus: '<svg xmlns="http://www.w3.org/2000/svg" class="h-4 w-4" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path stroke-linecap="round" stroke-linejoin="round" d="M12 4v16m8-8H4" /></svg>',
|
|
20
13
|
book: '<svg xmlns="http://www.w3.org/2000/svg" class="h-4 w-4" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path stroke-linecap="round" stroke-linejoin="round" d="M12 6.253v13m0-13C10.832 5.477 9.246 5 7.5 5S4.168 5.477 3 6.253v13C4.168 18.477 5.754 18 7.5 18s3.332.477 4.5 1.253m0-13C13.168 5.477 14.754 5 16.5 5c1.747 0 3.332.477 4.5 1.253v13C19.832 18.477 18.247 18 16.5 18c-1.746 0-3.332.477-4.5 1.253" /></svg>',
|
|
21
14
|
schema: '<svg xmlns="http://www.w3.org/2000/svg" class="h-4 w-4" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path stroke-linecap="round" stroke-linejoin="round" d="M10.325 4.317c.426-1.756 2.924-1.756 3.35 0a1.724 1.724 0 002.573 1.066c1.543-.94 3.31.826 2.37 2.37a1.724 1.724 0 001.065 2.572c1.756.426 1.756 2.924 0 3.35a1.724 1.724 0 00-1.066 2.573c.94 1.543-.826 3.31-2.37 2.37a1.724 1.724 0 00-2.572 1.065c-.426 1.756-2.924 1.756-3.35 0a1.724 1.724 0 00-2.573-1.066c-1.543.94-3.31-.826-2.37-2.37a1.724 1.724 0 00-1.065-2.572c-1.756-.426-1.756-2.924 0-3.35a1.724 1.724 0 001.066-2.573c-.94-1.543.826-3.31 2.37-2.37.996.608 2.296.07 2.572-1.065z" /><path stroke-linecap="round" stroke-linejoin="round" d="M15 12a3 3 0 11-6 0 3 3 0 016 0z" /></svg>',
|
|
22
|
-
|
|
15
|
+
diagram: '<svg xmlns="http://www.w3.org/2000/svg" class="h-4 w-4" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><rect x="2" y="3" width="6" height="5" rx="1" stroke-linecap="round" stroke-linejoin="round"/><rect x="16" y="3" width="6" height="5" rx="1" stroke-linecap="round" stroke-linejoin="round"/><rect x="9" y="16" width="6" height="5" rx="1" stroke-linecap="round" stroke-linejoin="round"/><path stroke-linecap="round" stroke-linejoin="round" d="M5 8v4h14V8M12 12v4"/></svg>',
|
|
23
16
|
search: '<svg xmlns="http://www.w3.org/2000/svg" class="h-4 w-4" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path stroke-linecap="round" stroke-linejoin="round" d="M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z" /></svg>',
|
|
24
17
|
filter: '<svg xmlns="http://www.w3.org/2000/svg" class="h-4 w-4" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path stroke-linecap="round" stroke-linejoin="round" d="M3 4a1 1 0 011-1h16a1 1 0 011 1v2.586a1 1 0 01-.293.707l-6.414 6.414A1 1 0 0014 15.414V20a1 1 0 01-1 1h-2a1 1 0 01-1-1v-4.586a1 1 0 00-.293-.707L3.293 7.293A1 1 0 013 6.586V4z" /></svg>',
|
|
25
18
|
export: '<svg xmlns="http://www.w3.org/2000/svg" class="h-4 w-4" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path stroke-linecap="round" stroke-linejoin="round" d="M4 16v1a3 3 0 003 3h10a3 3 0 003-3v-1m-4-4l-4 4m0 0l-4-4m4 4V4" /></svg>',
|
|
@@ -33,7 +26,7 @@ exports.ICONS = {
|
|
|
33
26
|
run: '<svg xmlns="http://www.w3.org/2000/svg" class="h-4 w-4" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path stroke-linecap="round" stroke-linejoin="round" d="M14.752 11.168l-3.197-2.132A1 1 0 0010 9.87v4.263a1 1 0 001.555.832l3.197-2.132a1 1 0 000-1.664z" /><path stroke-linecap="round" stroke-linejoin="round" d="M21 12a9 9 0 11-18 0 9 9 0 0118 0z" /></svg>',
|
|
34
27
|
inspect: '<svg xmlns="http://www.w3.org/2000/svg" class="h-4 w-4" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path stroke-linecap="round" stroke-linejoin="round" d="M15 12a3 3 0 11-6 0 3 3 0 016 0z"/><path stroke-linecap="round" stroke-linejoin="round" d="M2.458 12C3.732 7.943 7.523 5 12 5c4.478 0 8.268 2.943 9.542 7-1.274 4.057-5.064 7-9.542 7-4.477 0-8.268-2.943-9.542-7z"/></svg>',
|
|
35
28
|
sql: '<svg xmlns="http://www.w3.org/2000/svg" class="h-4 w-4" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path stroke-linecap="round" stroke-linejoin="round" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2" /></svg>',
|
|
36
|
-
|
|
29
|
+
settings: '<svg xmlns="http://www.w3.org/2000/svg" class="h-4 w-4" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path stroke-linecap="round" stroke-linejoin="round" d="M10.325 4.317c.426-1.756 2.924-1.756 3.35 0a1.724 1.724 0 002.573 1.066c1.543-.94 3.31.826 2.37 2.37a1.724 1.724 0 001.065 2.572c1.756.426 1.756 2.924 0 3.35a1.724 1.724 0 00-1.066 2.573c.94 1.543-.826 3.31-2.37 2.37a1.724 1.724 0 00-2.572 1.065c-.426 1.756-2.924 1.756-3.35 0a1.724 1.724 0 00-2.573-1.066c-1.543.94-3.31-.826-2.37-2.37a1.724 1.724 0 00-1.065-2.572c-1.756-.426-1.756-2.924 0-3.35a1.724 1.724 0 001.066-2.573c-.94-1.543.826-3.31 2.37-2.37.996.608 2.296.07 2.572-1.065z" /><path stroke-linecap="round" stroke-linejoin="round" d="M15 12a3 3 0 11-6 0 3 3 0 016 0z" /></svg>',
|
|
37
30
|
chevronDown: '<svg xmlns="http://www.w3.org/2000/svg" class="h-4 w-4" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path stroke-linecap="round" stroke-linejoin="round" d="M19 9l-7 7-7-7" /></svg>',
|
|
38
31
|
chevronUp: '<svg xmlns="http://www.w3.org/2000/svg" class="h-4 w-4" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path stroke-linecap="round" stroke-linejoin="round" d="M5 15l7-7 7 7" /></svg>',
|
|
39
32
|
chevronLeft: '<svg xmlns="http://www.w3.org/2000/svg" class="h-4 w-4" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path stroke-linecap="round" stroke-linejoin="round" d="M15 19l-7-7 7-7" /></svg>',
|
|
@@ -41,7 +34,17 @@ exports.ICONS = {
|
|
|
41
34
|
arrowLeft: '<svg xmlns="http://www.w3.org/2000/svg" class="h-4 w-4" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path stroke-linecap="round" stroke-linejoin="round" d="M10 19l-7-7m0 0l7-7m-7 7h18" /></svg>',
|
|
42
35
|
arrowRight: '<svg xmlns="http://www.w3.org/2000/svg" class="h-4 w-4" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path stroke-linecap="round" stroke-linejoin="round" d="M13 7l5 5m0 0l-5 5m5-5H6" /></svg>',
|
|
43
36
|
arrowUp: '<svg xmlns="http://www.w3.org/2000/svg" class="h-4 w-4" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path stroke-linecap="round" stroke-linejoin="round" d="M3 10h13M3 10l4-4m-4 4l4 4" /></svg>',
|
|
44
|
-
|
|
37
|
+
refresh: '<svg xmlns="http://www.w3.org/2000/svg" class="h-4 w-4" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path stroke-linecap="round" stroke-linejoin="round" d="M4 4v5h.582m15.356 2A8.001 8.001 0 004.582 9m0 0H9m11 11v-5h-.581m0 0a8.003 8.003 0 01-15.357-2m15.357 2H15" /></svg>',
|
|
38
|
+
compact: '<svg xmlns="http://www.w3.org/2000/svg" class="h-4 w-4" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path stroke-linecap="round" stroke-linejoin="round" d="M4 8h16M4 16h16"/></svg>',
|
|
39
|
+
fit: '<svg xmlns="http://www.w3.org/2000/svg" class="h-4 w-4" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path stroke-linecap="round" stroke-linejoin="round" d="M4 8V4m0 0h4M4 4l5 5m11-1V4m0 0h-4m4 0l5-5M4 16v4m0 0h4m-4 0l5-5m11 5v-4m0 0h-4m4 0l-5-5"/></svg>',
|
|
40
|
+
layoutForce: '<svg xmlns="http://www.w3.org/2000/svg" class="h-4 w-4" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><circle cx="12" cy="12" r="3"/><circle cx="4" cy="5" r="2"/><circle cx="20" cy="5" r="2"/><circle cx="4" cy="19" r="2"/><circle cx="20" cy="19" r="2"/><path stroke-linecap="round" d="M6 6.5l4.5 4M17.5 6.5l-4 4M6 17.5l4.5-4M17.5 17.5l-4-4"/></svg>',
|
|
41
|
+
layoutHierarchy: '<svg xmlns="http://www.w3.org/2000/svg" class="h-4 w-4" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><rect x="2" y="9" width="5" height="6" rx="1"/><rect x="9" y="4" width="5" height="6" rx="1"/><rect x="9" y="14" width="5" height="6" rx="1"/><rect x="17" y="9" width="5" height="6" rx="1"/><path stroke-linecap="round" d="M7 12h2M14 7h1l2 5-2 5h-1"/></svg>',
|
|
42
|
+
layoutCircle: '<svg xmlns="http://www.w3.org/2000/svg" class="h-4 w-4" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><circle cx="12" cy="12" r="9"/><circle cx="12" cy="3" r="1.5" fill="currentColor" stroke="none"/><circle cx="20.2" cy="7.5" r="1.5" fill="currentColor" stroke="none"/><circle cx="20.2" cy="16.5" r="1.5" fill="currentColor" stroke="none"/><circle cx="12" cy="21" r="1.5" fill="currentColor" stroke="none"/><circle cx="3.8" cy="16.5" r="1.5" fill="currentColor" stroke="none"/><circle cx="3.8" cy="7.5" r="1.5" fill="currentColor" stroke="none"/></svg>',
|
|
43
|
+
minus: '<svg xmlns="http://www.w3.org/2000/svg" class="h-4 w-4" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path stroke-linecap="round" stroke-linejoin="round" d="M20 12H4"/></svg>',
|
|
44
|
+
focus: '<svg xmlns="http://www.w3.org/2000/svg" class="h-4 w-4" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><circle cx="11" cy="11" r="8"/><path stroke-linecap="round" stroke-linejoin="round" d="M21 21l-4.35-4.35M11 8v6m-3-3h6"/></svg>',
|
|
45
|
+
spinner: '<svg xmlns="http://www.w3.org/2000/svg" class="h-4 w-4" fill="none" viewBox="0 0 24 24"><circle class="opacity-25" cx="12" cy="12" r="10" stroke="currentColor" stroke-width="4"></circle><path class="opacity-75" fill="currentColor" d="M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"></path></svg>',
|
|
46
|
+
terminal: '<svg xmlns="http://www.w3.org/2000/svg" class="h-4 w-4" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path stroke-linecap="round" stroke-linejoin="round" d="M8 9l3 3-3 3m5 0h3M5 20h14a2 2 0 002-2V6a2 2 0 00-2-2H5a2 2 0 00-2 2v12a2 2 0 002 2z"/></svg>',
|
|
47
|
+
format: '<svg xmlns="http://www.w3.org/2000/svg" class="h-4 w-4" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path stroke-linecap="round" stroke-linejoin="round" d="M4 6h16M4 12h10M4 18h14"/></svg>',
|
|
45
48
|
check: '<svg xmlns="http://www.w3.org/2000/svg" class="h-4 w-4" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path stroke-linecap="round" stroke-linejoin="round" d="M5 13l4 4L19 7" /></svg>',
|
|
46
49
|
x: '<svg xmlns="http://www.w3.org/2000/svg" class="h-4 w-4" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path stroke-linecap="round" stroke-linejoin="round" d="M6 18L18 6M6 6l12 12" /></svg>',
|
|
47
50
|
warning: '<svg xmlns="http://www.w3.org/2000/svg" class="h-4 w-4" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path stroke-linecap="round" stroke-linejoin="round" d="M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z" /></svg>',
|
|
@@ -49,24 +52,30 @@ exports.ICONS = {
|
|
|
49
52
|
key: '<svg xmlns="http://www.w3.org/2000/svg" class="h-4 w-4" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path stroke-linecap="round" stroke-linejoin="round" d="M15 7a2 2 0 012 2m4 0a6 6 0 01-7.743 5.743L11 17H9v2H7v2H4a1 1 0 01-1-1v-2.586a1 1 0 01.293-.707l5.964-5.964A6 6 0 1121 9z" /></svg>',
|
|
50
53
|
dotsHorizontal: '<svg xmlns="http://www.w3.org/2000/svg" class="h-4 w-4" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path stroke-linecap="round" stroke-linejoin="round" d="M5 12h.01M12 12h.01M19 12h.01M6 12a1 1 0 11-2 0 1 1 0 012 0zm7 0a1 1 0 11-2 0 1 1 0 012 0zm7 0a1 1 0 11-2 0 1 1 0 012 0z" /></svg>',
|
|
51
54
|
dotsVertical: '<svg xmlns="http://www.w3.org/2000/svg" class="h-4 w-4" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path stroke-linecap="round" stroke-linejoin="round" d="M12 5v.01M12 12v.01M12 19v.01M12 6a1 1 0 110-2 1 1 0 010 2zm0 7a1 1 0 110-2 1 1 0 010 2zm0 7a1 1 0 110-2 1 1 0 010 2z" /></svg>',
|
|
52
|
-
// Auth & Account
|
|
53
55
|
user: '<svg xmlns="http://www.w3.org/2000/svg" class="h-4 w-4" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path stroke-linecap="round" stroke-linejoin="round" d="M16 7a4 4 0 11-8 0 4 4 0 018 0zM12 14a7 7 0 00-7 7h14a7 7 0 00-7-7z" /></svg>',
|
|
54
56
|
logout: '<svg xmlns="http://www.w3.org/2000/svg" class="h-4 w-4" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path stroke-linecap="round" stroke-linejoin="round" d="M17 16l4-4m0 0l-4-4m4 4H7m6 4v1a3 3 0 01-3 3H6a3 3 0 01-3-3V7a3 3 0 013-3h4a3 3 0 013 3v1" /></svg>',
|
|
55
57
|
lock: '<svg xmlns="http://www.w3.org/2000/svg" class="h-4 w-4" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path stroke-linecap="round" stroke-linejoin="round" d="M12 15v2m-6 4h12a2 2 0 002-2v-6a2 2 0 00-2-2H6a2 2 0 00-2 2v6a2 2 0 002 2zm10-10V7a4 4 0 00-8 0v4h8z" /></svg>',
|
|
58
|
+
error: '<svg xmlns="http://www.w3.org/2000/svg" class="h-5 w-5" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path stroke-linecap="round" stroke-linejoin="round" d="M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z" /></svg>',
|
|
59
|
+
success: '<svg xmlns="http://www.w3.org/2000/svg" class="h-5 w-5" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path stroke-linecap="round" stroke-linejoin="round" d="M5 13l4 4L19 7" /></svg>',
|
|
60
|
+
info: '<svg xmlns="http://www.w3.org/2000/svg" class="h-5 w-5" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path stroke-linecap="round" stroke-linejoin="round" d="M13 16h-1v-4h-1m1-4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z" /></svg>',
|
|
61
|
+
sun: '<svg xmlns="http://www.w3.org/2000/svg" class="h-5 w-5" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path stroke-linecap="round" stroke-linejoin="round" d="M12 3v1m0 16v1m9-9h-1M4 12H3m15.364 6.364l-.707-.707M6.343 6.343l-.707-.707m12.728 0l-.707.707M6.343 17.657l-.707.707M16 12a4 4 0 11-8 0 4 4 0 018 0z" /></svg>',
|
|
62
|
+
moon: '<svg xmlns="http://www.w3.org/2000/svg" class="h-5 w-5" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path stroke-linecap="round" stroke-linejoin="round" d="M20.354 15.354A9 9 0 018.646 3.646 9.003 9.003 0 0012 21a9.003 9.003 0 008.354-5.646z" /></svg>',
|
|
63
|
+
calendar: '<svg xmlns="http://www.w3.org/2000/svg" class="h-4 w-4" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path stroke-linecap="round" stroke-linejoin="round" d="M8 7V3m8 4V3m-9 8h10M5 21h14a2 2 0 002-2V7a2 2 0 00-2-2H5a2 2 0 00-2 2v12a2 2 0 002 2z" /></svg>',
|
|
64
|
+
folder: '<svg xmlns="http://www.w3.org/2000/svg" class="h-3.5 w-3.5" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path stroke-linecap="round" stroke-linejoin="round" d="M3 7a2 2 0 012-2h4l2 2h8a2 2 0 012 2v8a2 2 0 01-2 2H5a2 2 0 01-2-2V7z" /></svg>',
|
|
65
|
+
download: '<svg xmlns="http://www.w3.org/2000/svg" class="h-4 w-4" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path stroke-linecap="round" stroke-linejoin="round" d="M4 16v1a3 3 0 003 3h10a3 3 0 003-3v-1m-4-4l-4 4m0 0l-4-4m4 4V4" /></svg>',
|
|
66
|
+
upload: '<svg xmlns="http://www.w3.org/2000/svg" class="h-4 w-4" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path stroke-linecap="round" stroke-linejoin="round" d="M4 16v1a3 3 0 003 3h10a3 3 0 003-3v-1m-4-8l-4-4m0 0L8 8m4-4v12" /></svg>',
|
|
67
|
+
checkSm: '<svg xmlns="http://www.w3.org/2000/svg" class="h-3.5 w-3.5" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path stroke-linecap="round" stroke-linejoin="round" d="M5 13l4 4L19 7" /></svg>',
|
|
68
|
+
inspectSm: '<svg xmlns="http://www.w3.org/2000/svg" class="h-3.5 w-3.5" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path stroke-linecap="round" stroke-linejoin="round" d="M15 12a3 3 0 11-6 0 3 3 0 016 0z"/><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M2.458 12C3.732 7.943 7.523 5 12 5c4.478 0 8.268 2.943 9.542 7-1.274 4.057-5.064 7-9.542 7-4.477 0-8.268-2.943-9.542-7z"/></svg>',
|
|
69
|
+
checkMd: '<svg xmlns="http://www.w3.org/2000/svg" class="h-4 w-4" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path stroke-linecap="round" stroke-linejoin="round" d="M5 13l4 4L19 7" /></svg>',
|
|
56
70
|
};
|
|
57
|
-
/**
|
|
58
|
-
* Renders an SVG icon by name with optional custom CSS classes.
|
|
59
|
-
*/
|
|
60
71
|
function renderIcon(name, customClass) {
|
|
61
72
|
const svg = exports.ICONS[name];
|
|
62
73
|
if (!svg)
|
|
63
74
|
return '';
|
|
64
75
|
if (!customClass)
|
|
65
76
|
return svg;
|
|
66
|
-
// Replace existing class attribute or inject new one
|
|
67
77
|
if (svg.includes('class="')) {
|
|
68
78
|
return svg.replace(/class="[^"]*"/, `class="${customClass}"`);
|
|
69
79
|
}
|
|
70
80
|
return svg.replace('<svg', `<svg class="${customClass}"`);
|
|
71
81
|
}
|
|
72
|
-
//# sourceMappingURL=icons.js.map
|
package/dist/utils/index.d.ts
CHANGED
package/dist/utils/index.js
CHANGED
package/dist/utils/logger.d.ts
CHANGED
|
@@ -1,10 +1 @@
|
|
|
1
|
-
export type LogLevel
|
|
2
|
-
export interface Logger {
|
|
3
|
-
debug(...args: unknown[]): void;
|
|
4
|
-
info(...args: unknown[]): void;
|
|
5
|
-
warn(...args: unknown[]): void;
|
|
6
|
-
error(...args: unknown[]): void;
|
|
7
|
-
child(scope: string): Logger;
|
|
8
|
-
}
|
|
9
|
-
/** Minimal, color-enhanced console logger with level filtering and scoped children. */
|
|
10
|
-
export declare function createLogger(level?: LogLevel, scope?: string): Logger;
|
|
1
|
+
export type LogLevel='debug'|'info'|'warn'|'error';export interface Logger{debug(...args:unknown[]):void;info(...args:unknown[]):void;warn(...args:unknown[]):void;error(...args:unknown[]):void;child(scope:string):Logger;}export declare function createLogger(level?:LogLevel,scope?:string):Logger;
|
package/dist/utils/logger.js
CHANGED
|
@@ -14,10 +14,8 @@ const BADGES = {
|
|
|
14
14
|
warn: colors_1.c.yellow('[warn]'),
|
|
15
15
|
error: colors_1.c.red(colors_1.c.bold('[error]')),
|
|
16
16
|
};
|
|
17
|
-
/** Minimal, color-enhanced console logger with level filtering and scoped children. */
|
|
18
17
|
function createLogger(level = 'info', scope = 'admindb') {
|
|
19
18
|
const threshold = LEVELS[level] ?? LEVELS.info;
|
|
20
|
-
// Clean scope name (e.g. "admindb:db:users.db" -> "db:users.db")
|
|
21
19
|
const cleanScope = scope === 'admindb' || scope === 'app' ? '' : scope.replace(/^admindb:/, '');
|
|
22
20
|
const scopeTag = cleanScope ? colors_1.c.dim(colors_1.c.cyan(`[${cleanScope}]`)) : '';
|
|
23
21
|
const write = (lv, args) => {
|
|
@@ -26,7 +24,6 @@ function createLogger(level = 'info', scope = 'admindb') {
|
|
|
26
24
|
const time = colors_1.c.gray(formatTime());
|
|
27
25
|
const badge = BADGES[lv];
|
|
28
26
|
const prefix = [time, badge, scopeTag].filter(Boolean).join(' ');
|
|
29
|
-
// eslint-disable-next-line no-console
|
|
30
27
|
console.log(prefix, ...args);
|
|
31
28
|
};
|
|
32
29
|
return {
|
|
@@ -37,4 +34,3 @@ function createLogger(level = 'info', scope = 'admindb') {
|
|
|
37
34
|
child: (s) => createLogger(level, cleanScope ? `${cleanScope}:${s}` : s),
|
|
38
35
|
};
|
|
39
36
|
}
|
|
40
|
-
//# sourceMappingURL=logger.js.map
|