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.
Files changed (208) hide show
  1. package/README.md +262 -329
  2. package/dist/app.d.ts +25 -4
  3. package/dist/app.js +79 -15
  4. package/dist/app.js.map +1 -1
  5. package/dist/auth/config.d.ts +19 -0
  6. package/dist/auth/config.js +147 -0
  7. package/dist/auth/config.js.map +1 -0
  8. package/dist/auth/crypto.d.ts +27 -0
  9. package/dist/auth/crypto.js +133 -0
  10. package/dist/auth/crypto.js.map +1 -0
  11. package/dist/auth/index.d.ts +5 -0
  12. package/dist/auth/index.js +22 -0
  13. package/dist/auth/index.js.map +1 -0
  14. package/dist/auth/middleware.d.ts +14 -0
  15. package/dist/auth/middleware.js +100 -0
  16. package/dist/auth/middleware.js.map +1 -0
  17. package/dist/auth/routes.d.ts +7 -0
  18. package/dist/auth/routes.js +78 -0
  19. package/dist/auth/routes.js.map +1 -0
  20. package/dist/auth/types.d.ts +35 -0
  21. package/dist/auth/types.js +11 -0
  22. package/dist/auth/types.js.map +1 -0
  23. package/dist/cli/args.d.ts +45 -0
  24. package/dist/cli/args.js +328 -0
  25. package/dist/cli/args.js.map +1 -0
  26. package/dist/cli/config.d.ts +56 -0
  27. package/dist/cli/config.js +133 -0
  28. package/dist/cli/config.js.map +1 -0
  29. package/dist/cli/index.d.ts +4 -0
  30. package/dist/cli/index.js +21 -0
  31. package/dist/cli/index.js.map +1 -0
  32. package/dist/cli/runner.d.ts +1 -0
  33. package/dist/cli/runner.js +222 -0
  34. package/dist/cli/runner.js.map +1 -0
  35. package/dist/cli.js +2 -127
  36. package/dist/cli.js.map +1 -1
  37. package/dist/data/datasets.d.ts +17 -0
  38. package/dist/data/datasets.js +133 -0
  39. package/dist/data/datasets.js.map +1 -0
  40. package/dist/data/detector.d.ts +30 -0
  41. package/dist/data/detector.js +472 -0
  42. package/dist/data/detector.js.map +1 -0
  43. package/dist/data/engine.d.ts +10 -0
  44. package/dist/data/engine.js +211 -0
  45. package/dist/data/engine.js.map +1 -0
  46. package/dist/data/index.d.ts +5 -0
  47. package/dist/data/index.js +22 -0
  48. package/dist/data/index.js.map +1 -0
  49. package/dist/data/strategies.d.ts +30 -0
  50. package/dist/data/strategies.js +343 -0
  51. package/dist/data/strategies.js.map +1 -0
  52. package/dist/data/types.d.ts +73 -0
  53. package/dist/data/types.js +8 -0
  54. package/dist/data/types.js.map +1 -0
  55. package/dist/db/database.d.ts +14 -146
  56. package/dist/db/database.js +208 -461
  57. package/dist/db/database.js.map +1 -1
  58. package/dist/db/export.d.ts +2 -2
  59. package/dist/db/export.js +7 -2
  60. package/dist/db/export.js.map +1 -1
  61. package/dist/db/filters.d.ts +22 -0
  62. package/dist/db/filters.js +158 -0
  63. package/dist/db/filters.js.map +1 -0
  64. package/dist/db/index.d.ts +8 -0
  65. package/dist/db/index.js +25 -0
  66. package/dist/db/index.js.map +1 -0
  67. package/dist/db/introspection.d.ts +6 -0
  68. package/dist/db/introspection.js +172 -0
  69. package/dist/db/introspection.js.map +1 -0
  70. package/dist/db/manager.d.ts +32 -19
  71. package/dist/db/manager.js +203 -44
  72. package/dist/db/manager.js.map +1 -1
  73. package/dist/db/migrations.d.ts +5 -0
  74. package/dist/db/migrations.js +110 -0
  75. package/dist/db/migrations.js.map +1 -0
  76. package/dist/db/postgres.d.ts +85 -0
  77. package/dist/db/postgres.js +745 -0
  78. package/dist/db/postgres.js.map +1 -0
  79. package/dist/db/types.d.ts +206 -0
  80. package/dist/db/types.js +7 -0
  81. package/dist/db/types.js.map +1 -0
  82. package/dist/index.d.ts +9 -2
  83. package/dist/index.js +46 -4
  84. package/dist/index.js.map +1 -1
  85. package/dist/public/css/app.css +1 -1
  86. package/dist/public/css/input.css +74 -11
  87. package/dist/public/js/app.js +142 -0
  88. package/dist/public/js/browse.js +591 -104
  89. package/dist/public/js/databases.js +105 -13
  90. package/dist/public/js/designer.js +55 -2
  91. package/dist/public/js/forms.js +610 -28
  92. package/dist/public/js/icons.js +51 -0
  93. package/dist/public/js/inspector.js +638 -0
  94. package/dist/public/js/query.js +93 -3
  95. package/dist/public/js/schema.js +185 -52
  96. package/dist/public/js/seed.js +865 -152
  97. package/dist/routes/api/helpers.d.ts +42 -0
  98. package/dist/routes/api/helpers.js +133 -0
  99. package/dist/routes/api/helpers.js.map +1 -0
  100. package/dist/routes/api/import-export.d.ts +3 -0
  101. package/dist/routes/api/import-export.js +85 -0
  102. package/dist/routes/api/import-export.js.map +1 -0
  103. package/dist/routes/api/index.d.ts +4 -0
  104. package/dist/routes/api/index.js +37 -0
  105. package/dist/routes/api/index.js.map +1 -0
  106. package/dist/routes/api/query.d.ts +3 -0
  107. package/dist/routes/api/query.js +76 -0
  108. package/dist/routes/api/query.js.map +1 -0
  109. package/dist/routes/api/rows.d.ts +3 -0
  110. package/dist/routes/api/rows.js +373 -0
  111. package/dist/routes/api/rows.js.map +1 -0
  112. package/dist/routes/api/seed.d.ts +3 -0
  113. package/dist/routes/api/seed.js +82 -0
  114. package/dist/routes/api/seed.js.map +1 -0
  115. package/dist/routes/api/tables.d.ts +3 -0
  116. package/dist/routes/api/tables.js +160 -0
  117. package/dist/routes/api/tables.js.map +1 -0
  118. package/dist/routes/databases.d.ts +8 -11
  119. package/dist/routes/databases.js +100 -66
  120. package/dist/routes/databases.js.map +1 -1
  121. package/dist/routes/index.d.ts +3 -0
  122. package/dist/routes/index.js +20 -0
  123. package/dist/routes/index.js.map +1 -0
  124. package/dist/routes/pages.d.ts +3 -3
  125. package/dist/routes/pages.js +157 -64
  126. package/dist/routes/pages.js.map +1 -1
  127. package/dist/serverless.d.ts +40 -0
  128. package/dist/serverless.js +210 -0
  129. package/dist/serverless.js.map +1 -0
  130. package/dist/sql/generator.d.ts +7 -3
  131. package/dist/sql/generator.js +144 -7
  132. package/dist/sql/generator.js.map +1 -1
  133. package/dist/sql/index.d.ts +2 -0
  134. package/dist/sql/index.js +19 -0
  135. package/dist/sql/index.js.map +1 -0
  136. package/dist/types/api.d.ts +412 -0
  137. package/dist/types/api.js +9 -0
  138. package/dist/types/api.js.map +1 -0
  139. package/dist/utils/colors.d.ts +40 -0
  140. package/dist/utils/colors.js +64 -0
  141. package/dist/utils/colors.js.map +1 -0
  142. package/dist/{util.d.ts → utils/common.d.ts} +10 -6
  143. package/dist/{util.js → utils/common.js} +80 -13
  144. package/dist/utils/common.js.map +1 -0
  145. package/dist/utils/csv.js.map +1 -0
  146. package/dist/utils/datatype.d.ts +49 -0
  147. package/dist/utils/datatype.js +222 -0
  148. package/dist/utils/datatype.js.map +1 -0
  149. package/dist/utils/icons.d.ts +11 -0
  150. package/dist/utils/icons.js +72 -0
  151. package/dist/utils/icons.js.map +1 -0
  152. package/dist/utils/index.d.ts +4 -0
  153. package/dist/utils/index.js +21 -0
  154. package/dist/utils/index.js.map +1 -0
  155. package/dist/{logger.d.ts → utils/logger.d.ts} +1 -1
  156. package/dist/utils/logger.js +40 -0
  157. package/dist/utils/logger.js.map +1 -0
  158. package/dist/views/layouts/main.hbs +40 -11
  159. package/dist/views/pages/databases.hbs +182 -74
  160. package/dist/views/pages/designer.hbs +29 -11
  161. package/dist/views/pages/error.hbs +3 -3
  162. package/dist/views/pages/form.hbs +5 -3
  163. package/dist/views/pages/home.hbs +22 -13
  164. package/dist/views/pages/login.hbs +111 -0
  165. package/dist/views/pages/query.hbs +8 -6
  166. package/dist/views/pages/schema.hbs +41 -13
  167. package/dist/views/pages/seed.hbs +200 -54
  168. package/dist/views/pages/table.hbs +152 -72
  169. package/dist/views/partials/icon.hbs +2 -0
  170. package/dist/views/partials/navbar.hbs +69 -25
  171. package/dist/views/partials/sidebar.hbs +108 -94
  172. package/docs/API.md +144 -0
  173. package/docs/EXAMPLES.md +576 -0
  174. package/docs/SECURITY.md +265 -0
  175. package/package.json +15 -4
  176. package/dist/args.d.ts +0 -28
  177. package/dist/args.js +0 -187
  178. package/dist/args.js.map +0 -1
  179. package/dist/config.d.ts +0 -17
  180. package/dist/config.js +0 -23
  181. package/dist/config.js.map +0 -1
  182. package/dist/csv.js.map +0 -1
  183. package/dist/data/generator.d.ts +0 -86
  184. package/dist/data/generator.js +0 -1031
  185. package/dist/data/generator.js.map +0 -1
  186. package/dist/logger.js +0 -25
  187. package/dist/logger.js.map +0 -1
  188. package/dist/routes/api.d.ts +0 -9
  189. package/dist/routes/api.js +0 -848
  190. package/dist/routes/api.js.map +0 -1
  191. package/dist/test/classifier.test.d.ts +0 -1
  192. package/dist/test/classifier.test.js +0 -44
  193. package/dist/test/classifier.test.js.map +0 -1
  194. package/dist/test/csv.test.d.ts +0 -1
  195. package/dist/test/csv.test.js +0 -64
  196. package/dist/test/csv.test.js.map +0 -1
  197. package/dist/test/database.test.d.ts +0 -1
  198. package/dist/test/database.test.js +0 -402
  199. package/dist/test/database.test.js.map +0 -1
  200. package/dist/test/generator.test.d.ts +0 -1
  201. package/dist/test/generator.test.js +0 -132
  202. package/dist/test/generator.test.js.map +0 -1
  203. package/dist/test/manager.test.d.ts +0 -1
  204. package/dist/test/manager.test.js +0 -146
  205. package/dist/test/manager.test.js.map +0 -1
  206. package/dist/util.js.map +0 -1
  207. /package/dist/{csv.d.ts → utils/csv.d.ts} +0 -0
  208. /package/dist/{csv.js → utils/csv.js} +0 -0
@@ -88,16 +88,23 @@
88
88
 
89
89
  /* Inline (spreadsheet-style) cell editing */
90
90
  .js-inline-cell {
91
- cursor: text;
91
+ cursor: cell;
92
92
  position: relative;
93
+ transition: background-color 0.12s ease, box-shadow 0.12s ease;
93
94
  }
94
95
  .js-inline-cell:hover {
95
96
  box-shadow: inset 0 0 0 1px oklch(var(--p) / 0.45);
96
97
  }
98
+ .js-inline-cell.cell-focused {
99
+ box-shadow: inset 0 0 0 2px oklch(var(--p) / 0.95);
100
+ background: color-mix(in oklab, oklch(var(--b1)) 85%, oklch(var(--p) / 0.14));
101
+ z-index: 5;
102
+ }
97
103
  .js-inline-cell.js-editing {
98
- box-shadow: inset 0 0 0 2px oklch(var(--p) / 0.85);
104
+ box-shadow: inset 0 0 0 2px oklch(var(--p) / 0.95);
99
105
  cursor: default;
100
- background: color-mix(in oklab, oklch(var(--b1)) 88%, oklch(var(--p) / 0.16));
106
+ background: color-mix(in oklab, oklch(var(--b1)) 88%, oklch(var(--p) / 0.18));
107
+ z-index: 10;
101
108
  }
102
109
  .js-inline-cell.js-editing .js-cell-value {
103
110
  display: none;
@@ -106,22 +113,78 @@
106
113
  opacity: 0.55;
107
114
  }
108
115
 
109
- /* Pending (staged) edit — highlighted until the user presses Apply.
110
- Uses the theme's base color (--b1) + a primary tint so it renders
111
- correctly in both the light and dark (black) themes. */
116
+ /* Pending (staged) edit — highlighted until the user presses Apply. */
112
117
  .js-inline-cell.cell-dirty {
113
- background: color-mix(in oklab, oklch(var(--b1)) 90%, oklch(var(--p) / 0.14));
114
- box-shadow: inset 0 0 0 1px oklch(var(--p) / 0.75);
118
+ background: color-mix(in oklab, oklch(var(--b1)) 88%, oklch(var(--wa) / 0.18));
119
+ box-shadow: inset 0 0 0 1.5px oklch(var(--wa) / 0.85);
115
120
  }
116
121
  .js-inline-cell.cell-dirty::after {
117
122
  content: '';
118
123
  position: absolute;
119
- top: 4px;
120
- right: 4px;
124
+ top: 2px;
125
+ right: 2px;
121
126
  width: 6px;
122
127
  height: 6px;
123
128
  border-radius: 999px;
124
- background: oklch(var(--p));
129
+ background: oklch(var(--wa));
130
+ box-shadow: 0 0 6px oklch(var(--wa) / 0.8);
131
+ }
132
+
133
+ .cell-revert-btn {
134
+ display: inline-grid;
135
+ place-items: center;
136
+ width: 1.25rem;
137
+ height: 1.25rem;
138
+ border-radius: 9999px;
139
+ font-size: 0.75rem;
140
+ color: oklch(var(--wa));
141
+ background: transparent;
142
+ opacity: 0;
143
+ transition: opacity 0.15s ease, background-color 0.15s ease;
144
+ border: none;
145
+ cursor: pointer;
146
+ }
147
+ .cell-revert-btn:hover {
148
+ background: oklch(var(--wa) / 0.2);
149
+ }
150
+ td:hover .cell-revert-btn,
151
+ tr:hover .cell-revert-btn {
152
+ opacity: 1;
153
+ }
154
+
155
+ /* Compact table mode */
156
+ .table-compact th,
157
+ .table-compact td {
158
+ padding-top: 0.35rem !important;
159
+ padding-bottom: 0.35rem !important;
160
+ font-size: 12px !important;
161
+ }
162
+
163
+ /* Sticky Actions Column */
164
+ .sticky-col-actions {
165
+ @apply sticky right-0 bg-base-100/95 backdrop-blur-sm;
166
+ box-shadow: -3px 0 6px -2px rgba(0,0,0,0.06);
167
+ z-index: 10;
168
+ }
169
+ [data-theme='admindbDark'] .sticky-col-actions {
170
+ box-shadow: -3px 0 8px -2px rgba(0,0,0,0.35);
171
+ }
172
+
173
+ /* Elevate table row and action cell stacking context when dropdown is active */
174
+ tr:has(.dropdown:focus-within),
175
+ tr:focus-within {
176
+ position: relative;
177
+ z-index: 40;
178
+ }
179
+ td.sticky-col-actions:has(.dropdown:focus-within),
180
+ td.sticky-col-actions:focus-within {
181
+ z-index: 50;
182
+ }
183
+ .dropdown:focus-within {
184
+ z-index: 50;
185
+ }
186
+ .dropdown:focus-within > .dropdown-content {
187
+ z-index: 100 !important;
125
188
  }
126
189
 
127
190
  /* Sortable column headers */
@@ -106,6 +106,147 @@
106
106
  });
107
107
  }
108
108
 
109
+ // ---- Universal Confirm Dialog -------------------------------------------
110
+
111
+ function confirmDialog(options) {
112
+ return new Promise(function (resolve) {
113
+ if (typeof options === 'string') {
114
+ options = { message: options };
115
+ }
116
+ options = options || {};
117
+ var title = options.title || 'Confirm action';
118
+ var message = options.message || 'Are you sure you want to proceed?';
119
+ var confirmText = options.confirmText || (options.danger !== false ? 'Delete' : 'Confirm');
120
+ var cancelText = options.cancelText || 'Cancel';
121
+ var isDanger = options.danger !== false;
122
+ var requireMatch = options.requireInputMatch ? String(options.requireInputMatch).trim() : null;
123
+
124
+ var overlay = document.createElement('div');
125
+ overlay.className =
126
+ 'fixed inset-0 z-[100] flex items-center justify-center bg-black/60 backdrop-blur-xs p-4 opacity-0 transition-opacity duration-200';
127
+ overlay.setAttribute('role', 'dialog');
128
+ overlay.setAttribute('aria-modal', 'true');
129
+
130
+ var card = document.createElement('div');
131
+ card.className =
132
+ 'app-card w-full max-w-lg overflow-hidden shadow-2xl border border-base-300 transform scale-95 transition-transform duration-200';
133
+
134
+ var badgeColor = isDanger ? 'bg-error/10 text-error border-error/20' : 'bg-warning/10 text-warning border-warning/20';
135
+ var confirmBtnClass = isDanger ? 'btn-error text-white' : 'btn-primary';
136
+
137
+ var itemHtml = '';
138
+ if (options.item) {
139
+ var itemTypeLabel = options.itemType ? escapeHtml(options.itemType) + ': ' : '';
140
+ itemHtml =
141
+ '<div class="mb-3.5 flex items-center gap-2 rounded-xl border border-base-300 bg-base-200/60 px-3.5 py-2.5">' +
142
+ '<span class="text-xs font-semibold uppercase tracking-wider text-base-content/50">' + itemTypeLabel + '</span>' +
143
+ '<span class="font-mono text-sm font-bold text-base-content break-all">' + escapeHtml(options.item) + '</span>' +
144
+ '</div>';
145
+ }
146
+
147
+ var inputMatchHtml = '';
148
+ if (requireMatch) {
149
+ inputMatchHtml =
150
+ '<div class="mt-4 space-y-1.5">' +
151
+ '<label class="text-xs font-medium text-base-content/70">To confirm, type <span class="font-mono font-bold text-base-content select-all">' + escapeHtml(requireMatch) + '</span> below:</label>' +
152
+ '<input type="text" class="field-input font-mono js-confirm-input" placeholder="' + escapeHtml(options.requireInputPlaceholder || requireMatch) + '" autocomplete="off" spellcheck="false" />' +
153
+ '</div>';
154
+ }
155
+
156
+ var detailsHtml = options.detailsHtml ? '<div class="mt-3.5 max-h-48 overflow-y-auto rounded-xl border border-base-200 bg-base-200/40 p-3 text-xs leading-relaxed text-base-content/75">' + options.detailsHtml + '</div>' : '';
157
+
158
+ card.innerHTML =
159
+ '<div class="flex items-start justify-between gap-3 border-b border-base-200 px-6 py-4">' +
160
+ ' <div class="flex items-center gap-3">' +
161
+ ' <div class="grid h-10 w-10 shrink-0 place-items-center rounded-xl border ' + badgeColor + '">' +
162
+ (isDanger ? ICONS.warning : ICONS.info) +
163
+ ' </div>' +
164
+ ' <div>' +
165
+ ' <h3 class="text-base font-bold text-base-content">' + escapeHtml(title) + '</h3>' +
166
+ ' <p class="text-xs text-base-content/50 font-medium">' + (isDanger ? 'Destructive Action' : 'Action Confirmation') + '</p>' +
167
+ ' </div>' +
168
+ ' </div>' +
169
+ ' <button type="button" class="btn btn-ghost btn-xs btn-circle js-modal-cancel text-base-content/40 hover:text-base-content" aria-label="Close">&times;</button>' +
170
+ '</div>' +
171
+ '<div class="px-6 py-5">' +
172
+ itemHtml +
173
+ ' <p class="text-sm text-base-content/80 leading-relaxed">' + escapeHtml(message) + '</p>' +
174
+ detailsHtml +
175
+ inputMatchHtml +
176
+ '</div>' +
177
+ '<div class="flex flex-wrap items-center justify-end gap-2.5 border-t border-base-200 bg-base-200/30 px-6 py-4">' +
178
+ ' <button type="button" class="btn btn-ghost btn-sm js-modal-cancel">' + escapeHtml(cancelText) + '</button>' +
179
+ ' <button type="button" class="btn ' + confirmBtnClass + ' btn-sm js-modal-confirm" ' + (requireMatch ? 'disabled' : '') + '>' + escapeHtml(confirmText) + '</button>' +
180
+ '</div>';
181
+
182
+ overlay.appendChild(card);
183
+ document.body.appendChild(overlay);
184
+
185
+ requestAnimationFrame(function () {
186
+ overlay.classList.remove('opacity-0');
187
+ overlay.classList.add('opacity-100');
188
+ card.classList.remove('scale-95');
189
+ card.classList.add('scale-100');
190
+ });
191
+
192
+ var confirmBtn = card.querySelector('.js-modal-confirm');
193
+ var cancelBtns = card.querySelectorAll('.js-modal-cancel');
194
+ var inputEl = card.querySelector('.js-confirm-input');
195
+
196
+ if (inputEl) {
197
+ inputEl.addEventListener('input', function () {
198
+ var val = inputEl.value.trim();
199
+ confirmBtn.disabled = val !== requireMatch;
200
+ });
201
+ inputEl.addEventListener('keydown', function (e) {
202
+ if (e.key === 'Enter' && !confirmBtn.disabled) {
203
+ e.preventDefault();
204
+ finish(true);
205
+ }
206
+ });
207
+ setTimeout(function () { inputEl.focus(); }, 50);
208
+ } else {
209
+ var cancelBtn = card.querySelector('.js-modal-cancel');
210
+ if (cancelBtn) setTimeout(function () { cancelBtn.focus(); }, 50);
211
+ }
212
+
213
+ var finished = false;
214
+ function finish(result) {
215
+ if (finished) return;
216
+ finished = true;
217
+ document.removeEventListener('keydown', onKeyDown);
218
+ overlay.classList.remove('opacity-100');
219
+ overlay.classList.add('opacity-0');
220
+ card.classList.remove('scale-100');
221
+ card.classList.add('scale-95');
222
+ setTimeout(function () {
223
+ overlay.remove();
224
+ resolve(result);
225
+ }, 180);
226
+ }
227
+
228
+ function onKeyDown(e) {
229
+ if (e.key === 'Escape') {
230
+ e.preventDefault();
231
+ finish(false);
232
+ }
233
+ }
234
+ document.addEventListener('keydown', onKeyDown);
235
+
236
+ cancelBtns.forEach(function (btn) {
237
+ btn.addEventListener('click', function () { finish(false); });
238
+ });
239
+
240
+ confirmBtn.addEventListener('click', function () {
241
+ if (!confirmBtn.disabled) finish(true);
242
+ });
243
+
244
+ overlay.addEventListener('click', function (e) {
245
+ if (e.target === overlay) finish(false);
246
+ });
247
+ });
248
+ }
249
+
109
250
  document.addEventListener('DOMContentLoaded', function () {
110
251
  initTheme();
111
252
  initTableFilter();
@@ -115,6 +256,7 @@
115
256
  escapeHtml: escapeHtml,
116
257
  showToast: showToast,
117
258
  showError: function (message) { showToast(message, 'error'); },
259
+ confirm: confirmDialog,
118
260
  applyTheme: applyTheme,
119
261
  };
120
262
  })();