admindb 1.1.0 → 1.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.
Files changed (41) hide show
  1. package/README.md +276 -228
  2. package/dist/app.d.ts +12 -0
  3. package/dist/app.js +7 -0
  4. package/dist/app.js.map +1 -1
  5. package/dist/args.d.ts +28 -0
  6. package/dist/args.js +187 -0
  7. package/dist/args.js.map +1 -0
  8. package/dist/cli.js +85 -15
  9. package/dist/cli.js.map +1 -1
  10. package/dist/data/generator.d.ts +86 -0
  11. package/dist/data/generator.js +1031 -0
  12. package/dist/data/generator.js.map +1 -0
  13. package/dist/db/database.d.ts +4 -0
  14. package/dist/db/database.js +28 -1
  15. package/dist/db/database.js.map +1 -1
  16. package/dist/db/manager.d.ts +6 -0
  17. package/dist/db/manager.js +31 -0
  18. package/dist/db/manager.js.map +1 -1
  19. package/dist/public/css/app.css +1 -1
  20. package/dist/public/css/input.css +9 -2
  21. package/dist/public/js/browse.js +8 -1
  22. package/dist/public/js/databases.js +99 -1
  23. package/dist/public/js/seed.js +377 -0
  24. package/dist/routes/api.js +62 -0
  25. package/dist/routes/api.js.map +1 -1
  26. package/dist/routes/databases.d.ts +10 -0
  27. package/dist/routes/databases.js +97 -0
  28. package/dist/routes/databases.js.map +1 -1
  29. package/dist/routes/pages.js +24 -0
  30. package/dist/routes/pages.js.map +1 -1
  31. package/dist/util.d.ts +5 -0
  32. package/dist/util.js +13 -0
  33. package/dist/util.js.map +1 -1
  34. package/dist/views/layouts/main.hbs +1 -1
  35. package/dist/views/pages/databases.hbs +41 -0
  36. package/dist/views/pages/query.hbs +2 -2
  37. package/dist/views/pages/seed.hbs +86 -0
  38. package/dist/views/pages/table.hbs +5 -0
  39. package/dist/views/partials/navbar.hbs +1 -6
  40. package/dist/views/partials/sidebar.hbs +1 -6
  41. package/package.json +2 -2
@@ -54,12 +54,12 @@
54
54
  </span>
55
55
  <span class="text-[11px] text-base-content/40">Ctrl/⌘ + Enter to run</span>
56
56
  </div>
57
- <div class="p-3">
57
+ <div>
58
58
  <div class="sql-editor-wrap">
59
59
  <pre id="query-gutter" class="sql-gutter" aria-hidden="true">1</pre>
60
60
  <textarea id="query-sql" class="sql-input" rows="10" placeholder="SELECT * FROM users WHERE …" spellcheck="false"></textarea>
61
61
  </div>
62
- <div id="query-message" class="mt-3"></div>
62
+ <div id="query-message"></div>
63
63
  </div>
64
64
  </div>
65
65
 
@@ -0,0 +1,86 @@
1
+ <div class="space-y-5">
2
+ <!-- Header -->
3
+ <div class="flex flex-wrap items-center justify-between gap-3">
4
+ <div class="flex items-center gap-3">
5
+ <a href="{{basePath}}/tables/{{table}}" class="btn btn-circle btn-ghost btn-sm" aria-label="Back to table">
6
+ <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="M10 19l-7-7m0 0l7-7m-7 7h18" /></svg>
7
+ </a>
8
+ <div>
9
+ <h1 class="font-mono text-2xl font-bold tracking-tight">{{table}}</h1>
10
+ <p class="text-sm text-base-content/55">Data generator — fill the table with realistic rows in one transaction.</p>
11
+ </div>
12
+ </div>
13
+ <div class="flex flex-wrap gap-2">
14
+ {{#unless readonly}}
15
+ <button id="seed-preview" type="button" class="btn btn-outline btn-sm gap-1.5">
16
+ <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 20l4-16m4 4l4 4-4 4M6 16l-4-4 4-4" /></svg>
17
+ Preview SQL
18
+ </button>
19
+ <button id="seed-insert" type="button" class="btn btn-primary btn-sm gap-1.5">
20
+ <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 9v3m0 0v3m0-3h3m-3 0H9m12 0a9 9 0 11-18 0 9 9 0 0118 0z" /></svg>
21
+ Insert rows
22
+ </button>
23
+ {{else}}
24
+ <span class="inline-flex items-center gap-1.5 text-sm font-medium text-warning">
25
+ <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 15v2m0 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>
26
+ Read-only — you can preview generated SQL but not insert rows.
27
+ </span>
28
+ {{/unless}}
29
+ </div>
30
+ </div>
31
+
32
+ <!-- Row count -->
33
+ <div class="app-card p-4">
34
+ <div class="flex flex-wrap items-end gap-x-5 gap-y-3">
35
+ <div class="form-control w-44">
36
+ <label class="field-label" for="seed-count">Rows to generate</label>
37
+ <input id="seed-count" type="number" min="1" max="{{maxRows}}" value="10" class="field-input" />
38
+ </div>
39
+ <div class="flex items-center gap-1.5 pb-0.5">
40
+ {{#each quickCounts}}
41
+ <button type="button" class="seed-quick btn btn-outline btn-xs" data-n="{{this}}">{{this}}</button>
42
+ {{/each}}
43
+ </div>
44
+ <p class="pb-0.5 text-xs text-base-content/45">Up to <b class="tabular-nums">{{maxRows}}</b> rows. The insert is transactional — a failed row rolls everything back.</p>
45
+ </div>
46
+ </div>
47
+
48
+ <!-- Column strategies -->
49
+ <div class="flex flex-wrap items-center justify-between gap-2">
50
+ <h2 class="flex items-center gap-2 text-sm font-semibold uppercase tracking-wide text-base-content/45">
51
+ <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 11H5m14 0a2 2 0 012 2v6a2 2 0 01-2 2H5a2 2 0 01-2-2v-6a2 2 0 012-2m14 0V9a2 2 0 00-2-2M5 11V9a2 2 0 012-2m0 0V5a2 2 0 012-2h6a2 2 0 012 2v2M7 7h10" /></svg>
52
+ Column strategies
53
+ </h2>
54
+ <div class="flex flex-wrap items-center gap-1.5">
55
+ <button id="seed-apply-all" type="button" class="btn btn-ghost btn-xs gap-1">Apply strategy to all…</button>
56
+ <button id="seed-reset" type="button" class="btn btn-ghost btn-xs gap-1">Reset defaults</button>
57
+ </div>
58
+ </div>
59
+ <div id="seed-columns" class="grid grid-cols-1 gap-3 md:grid-cols-2 xl:grid-cols-3"></div>
60
+
61
+ <!-- Feedback (warnings) -->
62
+ <div id="seed-feedback" class="hidden"></div>
63
+
64
+ <!-- Generated SQL preview -->
65
+ <div id="seed-sql" class="hidden">
66
+ <div class="app-card">
67
+ <div class="flex items-center justify-between border-b border-base-200 px-5 py-3.5">
68
+ <h2 class="flex items-center gap-2 text-sm font-semibold uppercase tracking-wide text-base-content/45">
69
+ <span class="grid h-6 w-6 place-items-center rounded-md bg-primary/10 text-primary">
70
+ <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 20l4-16m4 4l4 4-4 4M6 16l-4-4 4-4" /></svg>
71
+ </span>
72
+ Generated SQL
73
+ </h2>
74
+ <button id="seed-copy" type="button" class="btn btn-ghost btn-xs gap-1">
75
+ <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="M8 7H5a2 2 0 00-2 2v9a2 2 0 002 2h9a2 2 0 002-2v-2m-4-7h3a2 2 0 012 2v9a2 2 0 01-2 2h-3" /></svg>
76
+ Copy
77
+ </button>
78
+ </div>
79
+ <div class="p-4">
80
+ <pre class="code-panel max-h-[32rem] overflow-auto"><code id="seed-sql-code"></code></pre>
81
+ </div>
82
+ </div>
83
+ </div>
84
+ </div>
85
+ <script id="seed-config" type="application/json">{{{json seedConfig}}}</script>
86
+ <script src="{{basePath}}/js/seed.js" defer></script>
@@ -39,6 +39,10 @@
39
39
  Import CSV
40
40
  </button>
41
41
  {{/unless}}
42
+ <a href="{{basePath}}/tables/{{table}}/seed" class="btn btn-outline btn-sm gap-1.5">
43
+ <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 3v4M3 5h4M6 17v4m-2-2h4m5-16l2.286 6.857L21 12l-5.714 2.143L13 21l-2.286-6.857L5 12l5.714-2.143L13 3z" /></svg>
44
+ Seed data
45
+ </a>
42
46
  <a href="{{basePath}}/query" class="btn btn-outline btn-sm gap-1.5">
43
47
  <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 10V3L4 14h7v7l9-11h-7z" /></svg>
44
48
  Query
@@ -246,6 +250,7 @@
246
250
  <div class="mt-2 flex gap-2">
247
251
  {{#unless readonly}}
248
252
  <a href="{{basePath}}/tables/{{table}}/rows/new" class="btn btn-primary btn-sm">Insert a row</a>
253
+ <a href="{{basePath}}/tables/{{table}}/seed" class="btn btn-outline btn-sm">Generate sample data</a>
249
254
  {{/unless}}
250
255
  <a href="{{basePath}}/query" class="btn btn-outline btn-sm">Run a query</a>
251
256
  </div>
@@ -9,12 +9,7 @@
9
9
  </div>
10
10
  <div class="flex-1">
11
11
  <a href="{{basePath}}/" class="flex items-center gap-2.5">
12
- <span class="grid h-9 w-9 place-items-center rounded-xl bg-gradient-to-br from-primary to-secondary text-white shadow-soft">
13
- <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">
14
- <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" />
15
- </svg>
16
- </span>
17
- <span class="text-lg font-bold tracking-tight">DB<span class="text-primary">Admin</span></span>
12
+ <span class="text-lg font-bold tracking-tight">Admin<span class="text-primary">DB</span></span>
18
13
  </a>
19
14
  </div>
20
15
  <div class="flex items-center gap-1.5">
@@ -1,12 +1,7 @@
1
1
  <aside class="flex h-full min-h-full w-72 flex-col bg-neutral text-neutral-content">
2
2
  <div class="flex items-center gap-2.5 px-5 pb-4 pt-5">
3
- <span class="grid h-9 w-9 shrink-0 place-items-center rounded-xl bg-gradient-to-br from-primary to-secondary text-white shadow-soft">
4
- <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">
5
- <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" />
6
- </svg>
7
- </span>
8
3
  <div>
9
- <div class="text-base font-bold leading-tight">AdminDB</div>
4
+ <div class="text-base font-bold leading-tight">AdminDB <span style="font-size: x-small">{{#if version}} v{{version}}{{/if}}</span></div>
10
5
  <div class="text-[11px] text-neutral-content/50">{{#if databasesMode}}Database manager{{else}}Database: {{dbId}}{{/if}}</div>
11
6
  </div>
12
7
  </div>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "admindb",
3
- "version": "1.1.0",
3
+ "version": "1.2.1",
4
4
  "description": "Browser-based SQLite database administration tool — embed it in your Express app or run it standalone.",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -57,7 +57,7 @@
57
57
  "@types/express": "^4.17.21",
58
58
  "@types/node": "^22.10.0",
59
59
  "concurrently": "^9.1.0",
60
- "cross-env": "^10.1.0",
60
+ "cross-env": "^7.0.3",
61
61
  "daisyui": "^4.12.0",
62
62
  "tailwindcss": "^3.4.17",
63
63
  "tsx": "^4.19.0",