admindb 2.2.1 → 2.3.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 +368 -364
- package/dist/app.js +25 -16
- package/dist/auth/config.d.ts +1 -1
- package/dist/auth/config.js +18 -30
- package/dist/auth/crypto.js +11 -21
- package/dist/auth/middleware.js +9 -16
- package/dist/auth/routes.js +9 -15
- package/dist/cli/args.d.ts +1 -1
- package/dist/cli/args.js +20 -29
- package/dist/cli/config.d.ts +1 -1
- package/dist/cli/config.js +15 -18
- package/dist/cli/runner.js +13 -13
- package/dist/data/chain.d.ts +1 -1
- package/dist/data/chain.js +40 -617
- package/dist/data/datasets.d.ts +1 -1
- package/dist/data/datasets.js +43 -1
- package/dist/data/detector.js +45 -21
- package/dist/data/engine.d.ts +1 -1
- package/dist/data/engine.js +483 -142
- package/dist/data/index.d.ts +1 -1
- package/dist/data/index.js +8 -0
- package/dist/data/prng.d.ts +1 -0
- package/dist/data/prng.js +73 -0
- package/dist/data/registry.d.ts +1 -0
- package/dist/data/registry.js +805 -0
- package/dist/data/schema-graph.d.ts +1 -0
- package/dist/data/schema-graph.js +210 -0
- package/dist/data/strategies.d.ts +1 -1
- package/dist/data/strategies.js +44 -283
- package/dist/data/templates.d.ts +1 -0
- package/dist/data/templates.js +134 -0
- package/dist/data/types.d.ts +1 -1
- package/dist/data/validator.d.ts +1 -0
- package/dist/data/validator.js +160 -0
- package/dist/db/database.js +9 -14
- package/dist/db/export.js +32 -55
- package/dist/db/filters.d.ts +1 -1
- package/dist/db/filters.js +15 -38
- package/dist/db/introspection.js +4 -7
- package/dist/db/manager.d.ts +1 -1
- package/dist/db/manager.js +48 -53
- package/dist/db/migrations.js +7 -14
- package/dist/db/postgres.js +30 -78
- package/dist/index.d.ts +1 -1
- package/dist/public/css/app.css +1 -1
- package/dist/public/js/browse.js +1 -1
- package/dist/public/js/inspector.js +1 -1
- package/dist/public/js/query.js +1 -1
- package/dist/public/js/seed.js +1 -1
- package/dist/routes/api/erd.js +3 -8
- package/dist/routes/api/helpers.d.ts +1 -1
- package/dist/routes/api/helpers.js +75 -25
- package/dist/routes/api/import-export.js +1 -2
- package/dist/routes/api/query.js +2 -6
- package/dist/routes/api/rows.js +4 -8
- package/dist/routes/api/seed.js +35 -21
- package/dist/routes/api/tables.js +15 -30
- package/dist/routes/databases.js +8 -26
- package/dist/routes/pages.js +67 -18
- package/dist/serverless.js +31 -44
- package/dist/sql/generator.d.ts +1 -1
- package/dist/sql/generator.js +35 -109
- package/dist/types/api.d.ts +1 -1
- package/dist/utils/common.d.ts +1 -1
- package/dist/utils/common.js +45 -85
- package/dist/utils/csv.d.ts +1 -1
- package/dist/utils/csv.js +11 -17
- package/dist/utils/datatype.js +46 -60
- package/dist/utils/icons.js +8 -8
- package/dist/views/layouts/main.hbs +1 -87
- package/dist/views/pages/databases.hbs +1 -233
- package/dist/views/pages/designer.hbs +1 -89
- package/dist/views/pages/erd.hbs +1 -1241
- package/dist/views/pages/error.hbs +1 -10
- package/dist/views/pages/form.hbs +1 -59
- package/dist/views/pages/home.hbs +1 -220
- package/dist/views/pages/info.hbs +1 -107
- package/dist/views/pages/login.hbs +1 -98
- package/dist/views/pages/query.hbs +1 -129
- package/dist/views/pages/schema.hbs +1 -298
- package/dist/views/pages/seed-select.hbs +251 -0
- package/dist/views/pages/seed.hbs +256 -414
- package/dist/views/pages/table.hbs +1 -327
- package/dist/views/partials/navbar.hbs +1 -83
- package/dist/views/partials/sidebar.hbs +1 -129
- package/docs/API.md +149 -149
- package/docs/EXAMPLES.md +579 -579
- package/docs/SECURITY.md +265 -265
- package/package.json +80 -79
package/dist/data/index.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export * from './types';export * from './datasets';export * from './strategies';export * from './detector';export * from './engine';export * from './chain';
|
|
1
|
+
export * from './types';export * from './datasets';export * from './prng';export{GeneratorRegistry,generateColumnValue,type GeneratorDefinition,type GeneratorFn,type GeneratorContext} from './registry';export * from './templates';export * from './schema-graph';export * from './validator';export * from './strategies';export * from './detector';export * from './engine';export * from './chain';
|
package/dist/data/index.js
CHANGED
|
@@ -14,8 +14,16 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
exports.generateColumnValue = exports.GeneratorRegistry = void 0;
|
|
17
18
|
__exportStar(require("./types"), exports);
|
|
18
19
|
__exportStar(require("./datasets"), exports);
|
|
20
|
+
__exportStar(require("./prng"), exports);
|
|
21
|
+
var registry_1 = require("./registry");
|
|
22
|
+
Object.defineProperty(exports, "GeneratorRegistry", { enumerable: true, get: function () { return registry_1.GeneratorRegistry; } });
|
|
23
|
+
Object.defineProperty(exports, "generateColumnValue", { enumerable: true, get: function () { return registry_1.generateColumnValue; } });
|
|
24
|
+
__exportStar(require("./templates"), exports);
|
|
25
|
+
__exportStar(require("./schema-graph"), exports);
|
|
26
|
+
__exportStar(require("./validator"), exports);
|
|
19
27
|
__exportStar(require("./strategies"), exports);
|
|
20
28
|
__exportStar(require("./detector"), exports);
|
|
21
29
|
__exportStar(require("./engine"), exports);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export interface RandomSource{next():number;int(min:number,max:number):number;float(min:number,max:number):number;pick<T>(arr:readonly T[]):T;pickMany<T>(arr:readonly T[],count:number,unique?:boolean):T[];shuffle<T>(arr:T[]):T[];weightedPick<T>(items:readonly T[],weights:readonly number[]):T;chance(pct:number):boolean;}export declare function createPrng(seed?:number|null):RandomSource;
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createPrng = createPrng;
|
|
4
|
+
function createPrng(seed) {
|
|
5
|
+
let s = seed != null && Number.isFinite(seed) ? Math.floor(Math.abs(seed)) : null;
|
|
6
|
+
function next() {
|
|
7
|
+
if (s === null)
|
|
8
|
+
return Math.random();
|
|
9
|
+
s |= 0;
|
|
10
|
+
s = (s + 0x6d2b79f5) | 0;
|
|
11
|
+
let t = Math.imul(s ^ (s >>> 15), 1 | s);
|
|
12
|
+
t = (t + Math.imul(t ^ (t >>> 7), 61 | t)) ^ t;
|
|
13
|
+
return ((t ^ (t >>> 14)) >>> 0) / 4294967296;
|
|
14
|
+
}
|
|
15
|
+
const int = (min, max) => {
|
|
16
|
+
const lo = Math.min(min, max);
|
|
17
|
+
const hi = Math.max(min, max);
|
|
18
|
+
return Math.floor(next() * (hi - lo + 1)) + lo;
|
|
19
|
+
};
|
|
20
|
+
const float = (min, max) => {
|
|
21
|
+
const lo = Math.min(min, max);
|
|
22
|
+
const hi = Math.max(min, max);
|
|
23
|
+
return next() * (hi - lo) + lo;
|
|
24
|
+
};
|
|
25
|
+
const pick = (arr) => (!arr || arr.length === 0 ? undefined : arr[int(0, arr.length - 1)]);
|
|
26
|
+
const shuffle = (arr) => {
|
|
27
|
+
for (let i = arr.length - 1; i > 0; i--) {
|
|
28
|
+
const j = int(0, i);
|
|
29
|
+
const temp = arr[i];
|
|
30
|
+
arr[i] = arr[j];
|
|
31
|
+
arr[j] = temp;
|
|
32
|
+
}
|
|
33
|
+
return arr;
|
|
34
|
+
};
|
|
35
|
+
const pickMany = (arr, count, unique = false) => {
|
|
36
|
+
if (!arr || !arr.length || count <= 0)
|
|
37
|
+
return [];
|
|
38
|
+
if (!unique) {
|
|
39
|
+
return Array.from({ length: count }, () => pick(arr));
|
|
40
|
+
}
|
|
41
|
+
const pool = [...arr];
|
|
42
|
+
shuffle(pool);
|
|
43
|
+
return pool.slice(0, Math.min(count, pool.length));
|
|
44
|
+
};
|
|
45
|
+
const weightedPick = (items, weights) => {
|
|
46
|
+
if (!items.length)
|
|
47
|
+
return undefined;
|
|
48
|
+
if (items.length !== weights.length)
|
|
49
|
+
return pick(items);
|
|
50
|
+
const total = weights.reduce((acc, w) => acc + Math.max(0, w), 0);
|
|
51
|
+
if (total <= 0)
|
|
52
|
+
return pick(items);
|
|
53
|
+
const r = float(0, total);
|
|
54
|
+
let acc = 0;
|
|
55
|
+
for (let i = 0; i < items.length; i++) {
|
|
56
|
+
acc += Math.max(0, weights[i]);
|
|
57
|
+
if (r <= acc)
|
|
58
|
+
return items[i];
|
|
59
|
+
}
|
|
60
|
+
return items[items.length - 1];
|
|
61
|
+
};
|
|
62
|
+
const chance = (pct) => float(0, 100) < pct;
|
|
63
|
+
return {
|
|
64
|
+
next,
|
|
65
|
+
int,
|
|
66
|
+
float,
|
|
67
|
+
pick,
|
|
68
|
+
pickMany,
|
|
69
|
+
shuffle,
|
|
70
|
+
weightedPick,
|
|
71
|
+
chance,
|
|
72
|
+
};
|
|
73
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import type {ColumnInfo,ForeignKeyInfo} from '../db/index';import type {RandomSource} from './prng';import{type ColumnPlan,type GeneratorStrategyId,type StrategyCategory,type StrategyDescriptor} from './types';export interface GeneratorContext{rowIndex:number;col:ColumnInfo;plan:ColumnPlan;prng:RandomSource;rowValues?:Record<string,unknown>;fkPool?:unknown[];sampledPool?:unknown[];}export type GeneratorFn=(ctx:GeneratorContext)=>unknown;export interface GeneratorDefinition{id:GeneratorStrategyId;label:string;category:StrategyCategory;description:string;targetTypes:'all'|'text'|'numeric'|'blob'|'date';generate:GeneratorFn;}export declare function makeSlug(prng:RandomSource):string;export declare function makeEmail(prng:RandomSource,idx?:number,rowValues?:Record<string,unknown>):string;export declare function makeUsername(prng:RandomSource,idx?:number,rowValues?:Record<string,unknown>):string;export declare function makePhone(prng:RandomSource):string;export declare function makeAddress(prng:RandomSource):string;export declare function makeIp(prng:RandomSource):string;export declare function makeMacAddress(prng:RandomSource):string;export declare function makeCreditCard(prng:RandomSource):string;export declare function makeAvatar(prng:RandomSource,seedVal?:string):string;export declare function makeColor(prng:RandomSource,format?:string):string;export declare function makeUuid(prng:RandomSource):string;export declare function makeWords(prng:RandomSource,minLen:number,maxLen:number):string;export declare function makeSentences(prng:RandomSource,minLen:number,maxLen:number):string;export declare function makeParagraph(prng:RandomSource):string;export declare function formatPattern(pattern:string,prng:RandomSource):string;export declare function randomDate(prng:RandomSource, from ?:string,to?:string,kind?:'date'|'datetime'):string;export declare function randomTime(prng:RandomSource):string;export declare function randomUnixTimestamp(prng:RandomSource,format?:string, from ?:string,to?:string):number;export declare function randomAlnum(prng:RandomSource,minLen:number,maxLen:number):string;export declare function makeJsonObject(prng:RandomSource,keys?:string[],jsonValues?:Record<string,string[]>):string;export declare function isTextishType(type:string):boolean;declare class GeneratorRegistryClass{private registry;constructor();register(def:GeneratorDefinition):void;get(id:GeneratorStrategyId):GeneratorDefinition|undefined;getAll():GeneratorDefinition[];getDescriptorsFor(col:ColumnInfo,fk:ForeignKeyInfo|null):StrategyDescriptor[];private registerDefaults;}export declare const GeneratorRegistry:GeneratorRegistryClass;export declare function generateColumnValue(col:ColumnInfo,plan:ColumnPlan,prng?:RandomSource,rowIndex?:number,rowValues?:Record<string,unknown>,fkPool?:unknown[],sampledPool?:unknown[]):unknown;export{};
|