express-file-cluster 0.9.6 → 0.10.2
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/dist/auth/index.cjs +7 -6
- package/dist/auth/index.cjs.map +1 -1
- package/dist/auth/index.d.cts +1 -1
- package/dist/auth/index.d.ts +1 -1
- package/dist/auth/index.js +5 -5
- package/dist/chunk-3SWI46YK.js +74 -0
- package/dist/chunk-3SWI46YK.js.map +1 -0
- package/dist/{chunk-DCJOWFVD.cjs → chunk-4GHK27JA.cjs} +3 -3
- package/dist/{chunk-DCJOWFVD.cjs.map → chunk-4GHK27JA.cjs.map} +1 -1
- package/dist/{chunk-NI2BNGGV.js → chunk-5LPRKZPB.js} +2 -2
- package/dist/chunk-74BSJXWD.cjs +220 -0
- package/dist/chunk-74BSJXWD.cjs.map +1 -0
- package/dist/{chunk-6KHBJOLB.cjs → chunk-7BC3AN7R.cjs} +14 -14
- package/dist/{chunk-6KHBJOLB.cjs.map → chunk-7BC3AN7R.cjs.map} +1 -1
- package/dist/chunk-AGOYTFRO.cjs +42 -0
- package/dist/chunk-AGOYTFRO.cjs.map +1 -0
- package/dist/{chunk-HBYSKULC.js → chunk-B6MB6HEG.js} +5 -1
- package/dist/chunk-B6MB6HEG.js.map +1 -0
- package/dist/{chunk-OFA7OGN5.js → chunk-BG4A7Z32.js} +176 -7
- package/dist/chunk-BG4A7Z32.js.map +1 -0
- package/dist/{chunk-45BWAR6P.js → chunk-C2FOZ7ME.js} +4 -4
- package/dist/chunk-CGY7JU4Y.cjs +8 -0
- package/dist/chunk-CGY7JU4Y.cjs.map +1 -0
- package/dist/{chunk-BBSZLGZW.js → chunk-DN4TCGYB.js} +43 -14
- package/dist/chunk-DN4TCGYB.js.map +1 -0
- package/dist/{chunk-TI24L4XE.cjs → chunk-H2PVWCWC.cjs} +6 -2
- package/dist/chunk-H2PVWCWC.cjs.map +1 -0
- package/dist/{chunk-TYCYYLLM.cjs → chunk-IUZ6A7PB.cjs} +20 -53
- package/dist/chunk-IUZ6A7PB.cjs.map +1 -0
- package/dist/{chunk-DUADUR6R.cjs → chunk-JP36TLL4.cjs} +171 -14
- package/dist/chunk-JP36TLL4.cjs.map +1 -0
- package/dist/chunk-KLWL7XSC.js +220 -0
- package/dist/chunk-KLWL7XSC.js.map +1 -0
- package/dist/{chunk-QL6EWT4B.cjs → chunk-M53GODCX.cjs} +44 -15
- package/dist/chunk-M53GODCX.cjs.map +1 -0
- package/dist/{chunk-7ZESZG3J.js → chunk-MUVO7MGS.js} +4 -4
- package/dist/{chunk-VWSUQKCJ.cjs → chunk-R2K7AFIB.cjs} +286 -117
- package/dist/chunk-R2K7AFIB.cjs.map +1 -0
- package/dist/{chunk-ULWNHN6P.js → chunk-RETV3GKE.js} +9 -42
- package/dist/chunk-RETV3GKE.js.map +1 -0
- package/dist/{chunk-7YEX4MQV.cjs → chunk-RPL2IFWK.cjs} +46 -7
- package/dist/chunk-RPL2IFWK.cjs.map +1 -0
- package/dist/{chunk-FMA76PRH.cjs → chunk-TBIVIR6L.cjs} +15 -15
- package/dist/{chunk-FMA76PRH.cjs.map → chunk-TBIVIR6L.cjs.map} +1 -1
- package/dist/{chunk-73XJUT2S.js → chunk-V73R76I4.js} +162 -5
- package/dist/chunk-V73R76I4.js.map +1 -0
- package/dist/chunk-XPY5TQDK.js +42 -0
- package/dist/chunk-XPY5TQDK.js.map +1 -0
- package/dist/{chunk-RGT4ZVHL.cjs → chunk-Y4NKIXUL.cjs} +110 -55
- package/dist/chunk-Y4NKIXUL.cjs.map +1 -0
- package/dist/{chunk-2SETEVMO.js → chunk-Y75V5FCU.js} +100 -45
- package/dist/chunk-Y75V5FCU.js.map +1 -0
- package/dist/cli/db-runner.cjs +2059 -126
- package/dist/cli/db-runner.cjs.map +1 -1
- package/dist/cli/db-runner.js +2034 -102
- package/dist/cli/db-runner.js.map +1 -1
- package/dist/cli/index.cjs +50 -29
- package/dist/cli/index.cjs.map +1 -1
- package/dist/cli/index.js +39 -21
- package/dist/cli/index.js.map +1 -1
- package/dist/docs/api-reference/auth.md +23 -0
- package/dist/docs/api-reference/collection.md +44 -1
- package/dist/docs/api-reference/compose.md +1 -1
- package/dist/docs/api-reference/db.md +8 -0
- package/dist/docs/api-reference/ignite.md +13 -1
- package/dist/docs/api-reference/testing.md +26 -0
- package/dist/docs/api-reference/types.md +99 -0
- package/dist/docs/cli/add.md +2 -2
- package/dist/docs/cli/db.md +2 -2
- package/dist/docs/core-concepts/background-tasks.md +6 -3
- package/dist/docs/core-concepts/file-based-routing.md +2 -0
- package/dist/docs/core-concepts/middleware.md +2 -2
- package/dist/docs/getting-started/index.md +6 -1
- package/dist/docs/guides/authentication.md +33 -0
- package/dist/docs/guides/caching.md +34 -1
- package/dist/docs/guides/database.md +17 -0
- package/dist/docs/guides/environment-variables.md +6 -0
- package/dist/docs/guides/feature-matrix.md +58 -0
- package/dist/docs/guides/generated-portals.md +3 -1
- package/dist/docs/guides/logging.md +17 -0
- package/dist/docs/guides/migrations.md +26 -3
- package/dist/docs/guides/testing.md +31 -0
- package/dist/docs/guides/which-api.md +2 -2
- package/dist/docs/index.md +4 -1
- package/dist/docs/skills/SKILL.md +5 -1
- package/dist/docs/skills/api-surface.md +25 -4
- package/dist/docs/skills/auth-internals.md +14 -1
- package/dist/docs/skills/pre-flight.md +6 -0
- package/dist/docs/skills/routing-rules.md +1 -1
- package/dist/docs/skills/tasks-internals.md +4 -3
- package/dist/docs/skills/what-not-to-invent.md +13 -4
- package/dist/docs/versioning.md +1 -1
- package/dist/index.cjs +135 -255
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +228 -3
- package/dist/index.d.ts +228 -3
- package/dist/index.js +96 -217
- package/dist/index.js.map +1 -1
- package/dist/pgboss-backend-4X2YT4RB.js +14 -0
- package/dist/pgboss-backend-UXQ3O2WT.cjs +15 -0
- package/dist/pgboss-backend-UXQ3O2WT.cjs.map +1 -0
- package/dist/registry/index.json +39 -3
- package/dist/registry/js-mongo/account-security.json +1 -1
- package/dist/registry/js-mongo/admin-users.json +1 -1
- package/dist/registry/js-mongo/auth.json +1 -1
- package/dist/registry/js-mongo/auth@apple.json +1 -1
- package/dist/registry/js-mongo/auth@google.json +1 -1
- package/dist/registry/js-mongo/forgot-password.json +1 -1
- package/dist/registry/js-mongo/user-profile.json +1 -1
- package/dist/registry/js-mongo-collection/_base.json +1 -0
- package/dist/registry/js-mongo-collection/account-security.json +1 -0
- package/dist/registry/js-mongo-collection/account-settings.json +1 -0
- package/dist/registry/js-mongo-collection/admin-admins.json +1 -0
- package/dist/registry/js-mongo-collection/admin-analytics.json +1 -0
- package/dist/registry/js-mongo-collection/admin-billing.json +1 -0
- package/dist/registry/js-mongo-collection/admin-content.json +1 -0
- package/dist/registry/js-mongo-collection/admin-logs.json +1 -0
- package/dist/registry/js-mongo-collection/admin-support.json +1 -0
- package/dist/registry/js-mongo-collection/admin-system.json +1 -0
- package/dist/registry/js-mongo-collection/admin-users.json +1 -0
- package/dist/registry/js-mongo-collection/admin.json +1 -0
- package/dist/registry/js-mongo-collection/auth.json +1 -0
- package/dist/registry/js-mongo-collection/auth@apple.json +1 -0
- package/dist/registry/js-mongo-collection/auth@google.json +1 -0
- package/dist/registry/js-mongo-collection/billing.json +1 -0
- package/dist/registry/js-mongo-collection/email-client.json +1 -0
- package/dist/registry/js-mongo-collection/email-verification.json +1 -0
- package/dist/registry/js-mongo-collection/files.json +1 -0
- package/dist/registry/js-mongo-collection/forgot-password.json +1 -0
- package/dist/registry/js-mongo-collection/notifications.json +1 -0
- package/dist/registry/js-mongo-collection/support.json +1 -0
- package/dist/registry/js-mongo-collection/user-profile.json +1 -0
- package/dist/registry/js-pg-model/account-security.json +1 -1
- package/dist/registry/js-pg-model/admin-users.json +1 -1
- package/dist/registry/js-pg-model/auth.json +1 -1
- package/dist/registry/js-pg-model/auth@apple.json +1 -1
- package/dist/registry/js-pg-model/auth@google.json +1 -1
- package/dist/registry/js-pg-model/forgot-password.json +1 -1
- package/dist/registry/js-pg-model/user-profile.json +1 -1
- package/dist/registry/js-pg-table/account-security.json +1 -1
- package/dist/registry/js-pg-table/admin-users.json +1 -1
- package/dist/registry/js-pg-table/auth.json +1 -1
- package/dist/registry/js-pg-table/auth@apple.json +1 -1
- package/dist/registry/js-pg-table/auth@google.json +1 -1
- package/dist/registry/js-pg-table/forgot-password.json +1 -1
- package/dist/registry/js-pg-table/user-profile.json +1 -1
- package/dist/registry/ts-mongo/account-security.json +1 -1
- package/dist/registry/ts-mongo/admin-users.json +1 -1
- package/dist/registry/ts-mongo/auth.json +1 -1
- package/dist/registry/ts-mongo/auth@apple.json +1 -1
- package/dist/registry/ts-mongo/auth@google.json +1 -1
- package/dist/registry/ts-mongo/forgot-password.json +1 -1
- package/dist/registry/ts-mongo/user-profile.json +1 -1
- package/dist/registry/ts-mongo-collection/_base.json +1 -0
- package/dist/registry/ts-mongo-collection/account-security.json +1 -0
- package/dist/registry/ts-mongo-collection/account-settings.json +1 -0
- package/dist/registry/ts-mongo-collection/admin-admins.json +1 -0
- package/dist/registry/ts-mongo-collection/admin-analytics.json +1 -0
- package/dist/registry/ts-mongo-collection/admin-billing.json +1 -0
- package/dist/registry/ts-mongo-collection/admin-content.json +1 -0
- package/dist/registry/ts-mongo-collection/admin-logs.json +1 -0
- package/dist/registry/ts-mongo-collection/admin-support.json +1 -0
- package/dist/registry/ts-mongo-collection/admin-system.json +1 -0
- package/dist/registry/ts-mongo-collection/admin-users.json +1 -0
- package/dist/registry/ts-mongo-collection/admin.json +1 -0
- package/dist/registry/ts-mongo-collection/auth.json +1 -0
- package/dist/registry/ts-mongo-collection/auth@apple.json +1 -0
- package/dist/registry/ts-mongo-collection/auth@google.json +1 -0
- package/dist/registry/ts-mongo-collection/billing.json +1 -0
- package/dist/registry/ts-mongo-collection/email-client.json +1 -0
- package/dist/registry/ts-mongo-collection/email-verification.json +1 -0
- package/dist/registry/ts-mongo-collection/files.json +1 -0
- package/dist/registry/ts-mongo-collection/forgot-password.json +1 -0
- package/dist/registry/ts-mongo-collection/notifications.json +1 -0
- package/dist/registry/ts-mongo-collection/support.json +1 -0
- package/dist/registry/ts-mongo-collection/user-profile.json +1 -0
- package/dist/registry/ts-pg-model/account-security.json +1 -1
- package/dist/registry/ts-pg-model/admin-users.json +1 -1
- package/dist/registry/ts-pg-model/auth.json +1 -1
- package/dist/registry/ts-pg-model/auth@apple.json +1 -1
- package/dist/registry/ts-pg-model/auth@google.json +1 -1
- package/dist/registry/ts-pg-model/forgot-password.json +1 -1
- package/dist/registry/ts-pg-model/user-profile.json +1 -1
- package/dist/registry/ts-pg-table/account-security.json +1 -1
- package/dist/registry/ts-pg-table/admin-users.json +1 -1
- package/dist/registry/ts-pg-table/auth.json +1 -1
- package/dist/registry/ts-pg-table/auth@apple.json +1 -1
- package/dist/registry/ts-pg-table/auth@google.json +1 -1
- package/dist/registry/ts-pg-table/forgot-password.json +1 -1
- package/dist/registry/ts-pg-table/user-profile.json +1 -1
- package/dist/tasks/index.cjs +5 -2
- package/dist/tasks/index.cjs.map +1 -1
- package/dist/tasks/index.d.cts +4 -2
- package/dist/tasks/index.d.ts +4 -2
- package/dist/tasks/index.js +3 -1
- package/dist/testing-cjs.cjs +5 -0
- package/dist/testing.cjs +59 -0
- package/dist/testing.cjs.map +1 -0
- package/dist/testing.d.cts +27 -0
- package/dist/testing.d.ts +27 -0
- package/dist/testing.js +58 -0
- package/dist/testing.js.map +1 -0
- package/dist/thread-runner.cjs +9 -0
- package/dist/thread-runner.cjs.map +1 -0
- package/dist/thread-runner.d.cts +3 -0
- package/dist/thread-runner.d.ts +3 -0
- package/dist/thread-runner.js +8 -0
- package/dist/thread-runner.js.map +1 -0
- package/dist/{types-DAsBKVM-.d.ts → types-CPMFTVXm.d.cts} +15 -1
- package/dist/{types-DAsBKVM-.d.cts → types-CPMFTVXm.d.ts} +15 -1
- package/package.json +6 -1
- package/dist/chunk-2SETEVMO.js.map +0 -1
- package/dist/chunk-73XJUT2S.js.map +0 -1
- package/dist/chunk-7YEX4MQV.cjs.map +0 -1
- package/dist/chunk-BBSZLGZW.js.map +0 -1
- package/dist/chunk-DUADUR6R.cjs.map +0 -1
- package/dist/chunk-HBYSKULC.js.map +0 -1
- package/dist/chunk-LJNSJFOL.js +0 -38
- package/dist/chunk-LJNSJFOL.js.map +0 -1
- package/dist/chunk-OFA7OGN5.js.map +0 -1
- package/dist/chunk-QL6EWT4B.cjs.map +0 -1
- package/dist/chunk-RGT4ZVHL.cjs.map +0 -1
- package/dist/chunk-TI24L4XE.cjs.map +0 -1
- package/dist/chunk-TYCYYLLM.cjs.map +0 -1
- package/dist/chunk-ULWNHN6P.js.map +0 -1
- package/dist/chunk-VWSUQKCJ.cjs.map +0 -1
- package/dist/pgboss-backend-DSO3QTNK.cjs +0 -14
- package/dist/pgboss-backend-DSO3QTNK.cjs.map +0 -1
- package/dist/pgboss-backend-I6DFUNRM.js +0 -14
- /package/dist/{chunk-NI2BNGGV.js.map → chunk-5LPRKZPB.js.map} +0 -0
- /package/dist/{chunk-45BWAR6P.js.map → chunk-C2FOZ7ME.js.map} +0 -0
- /package/dist/{chunk-7ZESZG3J.js.map → chunk-MUVO7MGS.js.map} +0 -0
- /package/dist/{pgboss-backend-I6DFUNRM.js.map → pgboss-backend-4X2YT4RB.js.map} +0 -0
package/dist/cli/db-runner.cjs
CHANGED
|
@@ -1,28 +1,31 @@
|
|
|
1
1
|
"use strict"; function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { newObj[key] = obj[key]; } } } newObj.default = obj; return newObj; } } function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
|
|
2
2
|
|
|
3
3
|
|
|
4
|
-
var _chunkVWSUQKCJcjs = require('../chunk-VWSUQKCJ.cjs');
|
|
5
4
|
|
|
5
|
+
var _chunkR2K7AFIBcjs = require('../chunk-R2K7AFIB.cjs');
|
|
6
6
|
|
|
7
7
|
|
|
8
8
|
|
|
9
9
|
|
|
10
10
|
|
|
11
11
|
|
|
12
|
-
var _chunkQL6EWT4Bcjs = require('../chunk-QL6EWT4B.cjs');
|
|
13
12
|
|
|
13
|
+
var _chunkM53GODCXcjs = require('../chunk-M53GODCX.cjs');
|
|
14
14
|
|
|
15
15
|
|
|
16
16
|
|
|
17
17
|
|
|
18
18
|
|
|
19
19
|
|
|
20
|
-
var _chunkTYCYYLLMcjs = require('../chunk-TYCYYLLM.cjs');
|
|
21
20
|
|
|
21
|
+
var _chunkIUZ6A7PBcjs = require('../chunk-IUZ6A7PB.cjs');
|
|
22
|
+
require('../chunk-AGOYTFRO.cjs');
|
|
22
23
|
|
|
23
24
|
|
|
24
25
|
|
|
25
|
-
|
|
26
|
+
|
|
27
|
+
var _chunkJP36TLL4cjs = require('../chunk-JP36TLL4.cjs');
|
|
28
|
+
require('../chunk-CGY7JU4Y.cjs');
|
|
26
29
|
|
|
27
30
|
// src/cli/db-runner.ts
|
|
28
31
|
var _picocolors = require('picocolors'); var _picocolors2 = _interopRequireDefault(_picocolors);
|
|
@@ -175,18 +178,1645 @@ async function runSeeds(dir, engine, client, only, onRun) {
|
|
|
175
178
|
}
|
|
176
179
|
|
|
177
180
|
// src/db/studio.ts
|
|
181
|
+
var _crypto = require('crypto'); var _crypto2 = _interopRequireDefault(_crypto);
|
|
178
182
|
var _http = require('http'); var _http2 = _interopRequireDefault(_http);
|
|
183
|
+
|
|
184
|
+
// src/db/studio-page.ts
|
|
185
|
+
var STUDIO_HTML = `<!doctype html>
|
|
186
|
+
<html lang="en">
|
|
187
|
+
<head>
|
|
188
|
+
<meta charset="utf-8">
|
|
189
|
+
<title>EFC Studio</title>
|
|
190
|
+
<meta name="viewport" content="width=device-width,initial-scale=1">
|
|
191
|
+
<meta name="color-scheme" content="dark">
|
|
192
|
+
<style>
|
|
193
|
+
/* Exact client/ tokens */
|
|
194
|
+
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
|
|
195
|
+
[hidden] { display: none !important; }
|
|
196
|
+
|
|
197
|
+
:root {
|
|
198
|
+
color-scheme: dark;
|
|
199
|
+
--bg: #08090b;
|
|
200
|
+
--bg-card: #0e1014;
|
|
201
|
+
--bg-raised: #14171c;
|
|
202
|
+
--border: #1d2127;
|
|
203
|
+
--border-lit: #2b3038;
|
|
204
|
+
--text: #e8eaed;
|
|
205
|
+
--text-dim: #959ba5;
|
|
206
|
+
--text-muted: #5b616b;
|
|
207
|
+
--accent: #F0A030;
|
|
208
|
+
--accent-2: #f6c37a;
|
|
209
|
+
--accent-dim: rgba(240,160,48,.10);
|
|
210
|
+
--accent-glow:rgba(240,160,48,.22);
|
|
211
|
+
--purple: #b9a8f5;
|
|
212
|
+
--blue: #7cb6f2;
|
|
213
|
+
--orange: #f0a070;
|
|
214
|
+
--green: #8cc49f;
|
|
215
|
+
--red: #f07a72;
|
|
216
|
+
/* Local fonts only: the studio makes no outside requests (and works offline).
|
|
217
|
+
Inter / JetBrains Mono are used when installed, the system's fonts otherwise. */
|
|
218
|
+
--font-mono: 'JetBrains Mono', ui-monospace, 'SF Mono', 'Cascadia Code', Menlo, Consolas, monospace;
|
|
219
|
+
--font-sans: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
|
|
220
|
+
--r: 8px;
|
|
221
|
+
--radius-lg: 12px;
|
|
222
|
+
--ease-out: cubic-bezier(.16,1,.3,1);
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
html, body {
|
|
226
|
+
height: 100%;
|
|
227
|
+
margin: 0;
|
|
228
|
+
overflow: hidden;
|
|
229
|
+
background: var(--bg);
|
|
230
|
+
color: var(--text);
|
|
231
|
+
font-family: var(--font-sans);
|
|
232
|
+
font-size: 16px;
|
|
233
|
+
line-height: 1.5;
|
|
234
|
+
-webkit-font-smoothing: antialiased;
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
body {
|
|
238
|
+
display: flex;
|
|
239
|
+
flex-direction: column;
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
/* Global grid overlay \u2014 exact from client/workspace.css */
|
|
243
|
+
body::before {
|
|
244
|
+
content: '';
|
|
245
|
+
position: fixed;
|
|
246
|
+
inset: 0;
|
|
247
|
+
z-index: 0;
|
|
248
|
+
background-image:
|
|
249
|
+
linear-gradient(var(--border) 1px, transparent 1px),
|
|
250
|
+
linear-gradient(90deg, var(--border) 1px, transparent 1px);
|
|
251
|
+
background-size: 60px 60px;
|
|
252
|
+
opacity: .28;
|
|
253
|
+
pointer-events: none;
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
/* Scrollbars \u2014 exact from client/workspace.css */
|
|
257
|
+
::-webkit-scrollbar { width: 6px; height: 6px; }
|
|
258
|
+
::-webkit-scrollbar-track { background: var(--bg); }
|
|
259
|
+
::-webkit-scrollbar-thumb { background: var(--border-lit); border-radius: 3px; }
|
|
260
|
+
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }
|
|
261
|
+
* { scrollbar-width: thin; scrollbar-color: var(--border-lit) var(--bg); }
|
|
262
|
+
|
|
263
|
+
::selection { background: var(--accent); color: #111; }
|
|
264
|
+
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
|
|
265
|
+
|
|
266
|
+
/* \u2500\u2500\u2500 TOP BAR (exact from client/workspace.html .ws-topbar) \u2500\u2500\u2500 */
|
|
267
|
+
.ws-topbar {
|
|
268
|
+
flex-shrink: 0;
|
|
269
|
+
display: flex;
|
|
270
|
+
align-items: center;
|
|
271
|
+
gap: 16px;
|
|
272
|
+
height: 60px;
|
|
273
|
+
padding: 0 24px;
|
|
274
|
+
border-bottom: 1px solid var(--border);
|
|
275
|
+
background: var(--bg);
|
|
276
|
+
position: relative;
|
|
277
|
+
z-index: 10;
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
.logo {
|
|
281
|
+
font-family: var(--font-mono);
|
|
282
|
+
font-size: 1.25rem;
|
|
283
|
+
font-weight: 500;
|
|
284
|
+
letter-spacing: -.5px;
|
|
285
|
+
display: flex;
|
|
286
|
+
align-items: center;
|
|
287
|
+
gap: 10px;
|
|
288
|
+
color: var(--text);
|
|
289
|
+
user-select: none;
|
|
290
|
+
white-space: nowrap;
|
|
291
|
+
}
|
|
292
|
+
.logo-dot { color: var(--accent); }
|
|
293
|
+
.logo-img { width: 26px; height: 26px; color: var(--accent); flex-shrink: 0; }
|
|
294
|
+
|
|
295
|
+
.ws-topbar-label {
|
|
296
|
+
font-family: var(--font-mono);
|
|
297
|
+
font-size: 14px;
|
|
298
|
+
color: var(--text-muted);
|
|
299
|
+
white-space: nowrap;
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
.badge-group {
|
|
303
|
+
display: flex;
|
|
304
|
+
align-items: center;
|
|
305
|
+
gap: 8px;
|
|
306
|
+
white-space: nowrap;
|
|
307
|
+
}
|
|
308
|
+
.badge-engine, .badge-mode {
|
|
309
|
+
font-family: var(--font-mono);
|
|
310
|
+
font-size: 12.5px;
|
|
311
|
+
font-weight: 500;
|
|
312
|
+
padding: 3px 10px;
|
|
313
|
+
border-radius: 4px;
|
|
314
|
+
line-height: 1.35;
|
|
315
|
+
}
|
|
316
|
+
.badge-engine.pg { color: var(--blue); background: rgba(124,182,242,.12); border: 1px solid rgba(124,182,242,.28); }
|
|
317
|
+
.badge-engine.mongo { color: var(--green); background: rgba(140,196,159,.12); border: 1px solid rgba(140,196,159,.28); }
|
|
318
|
+
|
|
319
|
+
.badge-mode.write { color: var(--green); background: rgba(140,196,159,.12); border: 1px solid rgba(140,196,159,.28); }
|
|
320
|
+
.badge-mode.ro { color: var(--text-muted); background: var(--bg-raised); border: 1px solid var(--border); }
|
|
321
|
+
|
|
322
|
+
.topbar-spacer { flex: 1; }
|
|
323
|
+
|
|
324
|
+
/* \u2500\u2500\u2500 BUTTONS & CONTROLS (exact from client/style.css) \u2500\u2500\u2500 */
|
|
325
|
+
.btn-primary, .btn-ghost, .btn-danger {
|
|
326
|
+
display: inline-flex; align-items: center; justify-content: center; gap: 8px;
|
|
327
|
+
font-family: var(--font-sans);
|
|
328
|
+
font-weight: 500; font-size: 14px; line-height: 1;
|
|
329
|
+
padding: 9px 18px; border-radius: var(--r);
|
|
330
|
+
white-space: nowrap; cursor: pointer;
|
|
331
|
+
transition: background .15s, border-color .15s, color .15s, transform .15s;
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
.btn-primary {
|
|
335
|
+
background: var(--accent); color: #1a1100; border: 1px solid var(--accent);
|
|
336
|
+
}
|
|
337
|
+
.btn-primary:hover:not(:disabled) {
|
|
338
|
+
background: #f3b04f;
|
|
339
|
+
transform: translateY(-1px);
|
|
340
|
+
}
|
|
341
|
+
.btn-primary:disabled {
|
|
342
|
+
opacity: .4; cursor: default; transform: none;
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
.btn-ghost {
|
|
346
|
+
border: 1px solid var(--border-lit); color: var(--text-dim); background: transparent;
|
|
347
|
+
}
|
|
348
|
+
.btn-ghost:hover:not(:disabled) {
|
|
349
|
+
border-color: var(--accent);
|
|
350
|
+
color: var(--accent);
|
|
351
|
+
}
|
|
352
|
+
.btn-ghost:disabled {
|
|
353
|
+
opacity: .35; cursor: default;
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
.btn-icon { padding: 9px 12px; }
|
|
357
|
+
|
|
358
|
+
.btn-group { display: inline-flex; }
|
|
359
|
+
.btn-group .btn-ghost { border-radius: 0; }
|
|
360
|
+
.btn-group .btn-ghost:first-child {
|
|
361
|
+
border-top-left-radius: var(--r);
|
|
362
|
+
border-bottom-left-radius: var(--r);
|
|
363
|
+
}
|
|
364
|
+
.btn-group .btn-ghost:last-child {
|
|
365
|
+
border-top-right-radius: var(--r);
|
|
366
|
+
border-bottom-right-radius: var(--r);
|
|
367
|
+
margin-left: -1px;
|
|
368
|
+
}
|
|
369
|
+
|
|
370
|
+
.btn-danger {
|
|
371
|
+
background: rgba(240, 122, 114, .12);
|
|
372
|
+
border: 1px solid rgba(240, 122, 114, .35);
|
|
373
|
+
color: var(--red);
|
|
374
|
+
}
|
|
375
|
+
.btn-danger:hover:not(:disabled) {
|
|
376
|
+
background: var(--red);
|
|
377
|
+
color: #1a0808;
|
|
378
|
+
border-color: var(--red);
|
|
379
|
+
}
|
|
380
|
+
|
|
381
|
+
/* Tabbar \u2014 exact from client/workspace.css */
|
|
382
|
+
.tabbar {
|
|
383
|
+
display: flex;
|
|
384
|
+
background: var(--bg-card);
|
|
385
|
+
border: 1px solid var(--border);
|
|
386
|
+
border-radius: var(--r);
|
|
387
|
+
overflow: hidden;
|
|
388
|
+
flex-shrink: 0;
|
|
389
|
+
}
|
|
390
|
+
.tab-item {
|
|
391
|
+
display: flex;
|
|
392
|
+
align-items: center;
|
|
393
|
+
gap: 8px;
|
|
394
|
+
padding: 9px 16px;
|
|
395
|
+
font-family: var(--font-mono);
|
|
396
|
+
font-size: 13.5px;
|
|
397
|
+
color: var(--text-dim);
|
|
398
|
+
background: transparent;
|
|
399
|
+
border: 0;
|
|
400
|
+
border-right: 1px solid var(--border);
|
|
401
|
+
cursor: pointer;
|
|
402
|
+
transition: color .15s, background .15s;
|
|
403
|
+
user-select: none;
|
|
404
|
+
}
|
|
405
|
+
.tab-item:last-child { border-right: 0; }
|
|
406
|
+
.tab-item:hover:not(:disabled) { color: var(--text); }
|
|
407
|
+
.tab-item.active {
|
|
408
|
+
background: var(--bg-raised);
|
|
409
|
+
color: var(--text);
|
|
410
|
+
box-shadow: inset 0 -2px 0 var(--accent);
|
|
411
|
+
}
|
|
412
|
+
.tab-item:disabled { opacity: .35; cursor: default; }
|
|
413
|
+
|
|
414
|
+
/* Search Inputs \u2014 exact style.css install input */
|
|
415
|
+
.input-search-wrap {
|
|
416
|
+
display: flex;
|
|
417
|
+
align-items: center;
|
|
418
|
+
background: var(--bg-raised);
|
|
419
|
+
border: 1px solid var(--border-lit);
|
|
420
|
+
border-radius: var(--r);
|
|
421
|
+
padding: 8px 12px;
|
|
422
|
+
gap: 8px;
|
|
423
|
+
transition: border-color .15s, box-shadow .15s;
|
|
424
|
+
}
|
|
425
|
+
.input-search-wrap:focus-within {
|
|
426
|
+
border-color: var(--accent);
|
|
427
|
+
box-shadow: 0 0 0 1px var(--accent-glow);
|
|
428
|
+
}
|
|
429
|
+
.input-search-wrap svg { color: var(--text-dim); flex-shrink: 0; }
|
|
430
|
+
.input-search {
|
|
431
|
+
background: none;
|
|
432
|
+
border: 0;
|
|
433
|
+
color: var(--text);
|
|
434
|
+
font-family: var(--font-mono);
|
|
435
|
+
font-size: 13.5px;
|
|
436
|
+
outline: none;
|
|
437
|
+
width: 100%;
|
|
438
|
+
}
|
|
439
|
+
.input-search::placeholder { color: var(--text-muted); }
|
|
440
|
+
.clear-btn {
|
|
441
|
+
background: none;
|
|
442
|
+
border: 0;
|
|
443
|
+
color: var(--text-dim);
|
|
444
|
+
cursor: pointer;
|
|
445
|
+
font-size: 15px;
|
|
446
|
+
padding: 0 2px;
|
|
447
|
+
}
|
|
448
|
+
.clear-btn:hover { color: var(--text); }
|
|
449
|
+
|
|
450
|
+
/* \u2500\u2500\u2500 APP BODY (Sidebar + Editor Area) \u2500\u2500\u2500 */
|
|
451
|
+
.ws-body {
|
|
452
|
+
flex: 1;
|
|
453
|
+
display: flex;
|
|
454
|
+
min-height: 0;
|
|
455
|
+
position: relative;
|
|
456
|
+
z-index: 1;
|
|
457
|
+
}
|
|
458
|
+
|
|
459
|
+
aside {
|
|
460
|
+
width: 290px;
|
|
461
|
+
min-width: 290px;
|
|
462
|
+
background: var(--bg-card);
|
|
463
|
+
border-right: 1px solid var(--border);
|
|
464
|
+
display: flex;
|
|
465
|
+
flex-direction: column;
|
|
466
|
+
overflow: hidden;
|
|
467
|
+
}
|
|
468
|
+
|
|
469
|
+
.search-box {
|
|
470
|
+
padding: 14px 16px 10px;
|
|
471
|
+
position: relative;
|
|
472
|
+
}
|
|
473
|
+
|
|
474
|
+
.sidebar-header {
|
|
475
|
+
padding: 12px 18px 8px;
|
|
476
|
+
font-family: var(--font-mono);
|
|
477
|
+
font-size: 12px;
|
|
478
|
+
font-weight: 600;
|
|
479
|
+
letter-spacing: 1.2px;
|
|
480
|
+
text-transform: uppercase;
|
|
481
|
+
color: var(--text-muted);
|
|
482
|
+
display: flex;
|
|
483
|
+
justify-content: space-between;
|
|
484
|
+
align-items: center;
|
|
485
|
+
}
|
|
486
|
+
|
|
487
|
+
.table-tree {
|
|
488
|
+
flex: 1;
|
|
489
|
+
overflow-y: auto;
|
|
490
|
+
padding: 4px 10px 18px;
|
|
491
|
+
}
|
|
492
|
+
|
|
493
|
+
.tree-row {
|
|
494
|
+
display: flex;
|
|
495
|
+
align-items: center;
|
|
496
|
+
justify-content: space-between;
|
|
497
|
+
gap: 10px;
|
|
498
|
+
padding: 8px 12px;
|
|
499
|
+
margin-bottom: 3px;
|
|
500
|
+
border-radius: 6px;
|
|
501
|
+
font-size: 13.5px;
|
|
502
|
+
min-height: 38px;
|
|
503
|
+
color: var(--text-dim);
|
|
504
|
+
cursor: pointer;
|
|
505
|
+
white-space: nowrap;
|
|
506
|
+
user-select: none;
|
|
507
|
+
border: 1px solid transparent;
|
|
508
|
+
transition: background .15s, color .15s;
|
|
509
|
+
}
|
|
510
|
+
.tree-row:hover {
|
|
511
|
+
background: var(--bg-raised);
|
|
512
|
+
color: var(--text);
|
|
513
|
+
}
|
|
514
|
+
.tree-row.active {
|
|
515
|
+
background: var(--accent-dim);
|
|
516
|
+
color: var(--text);
|
|
517
|
+
box-shadow: inset 2px 0 0 var(--accent);
|
|
518
|
+
}
|
|
519
|
+
.tree-left {
|
|
520
|
+
display: flex;
|
|
521
|
+
align-items: center;
|
|
522
|
+
gap: 8px;
|
|
523
|
+
overflow: hidden;
|
|
524
|
+
min-width: 0;
|
|
525
|
+
}
|
|
526
|
+
.ico-table {
|
|
527
|
+
color: var(--text-muted);
|
|
528
|
+
flex-shrink: 0;
|
|
529
|
+
}
|
|
530
|
+
.tree-row.active .ico-table {
|
|
531
|
+
color: var(--accent);
|
|
532
|
+
}
|
|
533
|
+
.table-name {
|
|
534
|
+
overflow: hidden;
|
|
535
|
+
text-overflow: ellipsis;
|
|
536
|
+
white-space: nowrap;
|
|
537
|
+
}
|
|
538
|
+
.tree-row.active .table-name {
|
|
539
|
+
color: var(--accent-2);
|
|
540
|
+
font-weight: 600;
|
|
541
|
+
}
|
|
542
|
+
|
|
543
|
+
.count-badge {
|
|
544
|
+
font-family: var(--font-mono);
|
|
545
|
+
font-size: 12px;
|
|
546
|
+
color: var(--text-muted);
|
|
547
|
+
background: var(--bg-raised);
|
|
548
|
+
border: 1px solid var(--border);
|
|
549
|
+
padding: 2px 7px;
|
|
550
|
+
border-radius: 4px;
|
|
551
|
+
flex-shrink: 0;
|
|
552
|
+
}
|
|
553
|
+
.tree-row.active .count-badge {
|
|
554
|
+
background: rgba(240,160,48,.15);
|
|
555
|
+
border-color: rgba(240,160,48,.35);
|
|
556
|
+
color: var(--accent);
|
|
557
|
+
}
|
|
558
|
+
|
|
559
|
+
/* \u2500\u2500\u2500 WORKSPACE CONTENT \u2500\u2500\u2500 */
|
|
560
|
+
main {
|
|
561
|
+
flex: 1;
|
|
562
|
+
display: flex;
|
|
563
|
+
flex-direction: column;
|
|
564
|
+
min-width: 0;
|
|
565
|
+
background: var(--bg);
|
|
566
|
+
overflow: hidden;
|
|
567
|
+
}
|
|
568
|
+
|
|
569
|
+
.workspace-bar {
|
|
570
|
+
height: 50px;
|
|
571
|
+
min-height: 50px;
|
|
572
|
+
padding: 0 24px;
|
|
573
|
+
background: var(--bg-raised);
|
|
574
|
+
border-bottom: 1px solid var(--border);
|
|
575
|
+
display: flex;
|
|
576
|
+
align-items: center;
|
|
577
|
+
gap: 14px;
|
|
578
|
+
flex-shrink: 0;
|
|
579
|
+
}
|
|
580
|
+
.active-title {
|
|
581
|
+
font-family: var(--font-mono);
|
|
582
|
+
font-size: 16px;
|
|
583
|
+
font-weight: 600;
|
|
584
|
+
color: var(--text);
|
|
585
|
+
margin: 0;
|
|
586
|
+
white-space: nowrap;
|
|
587
|
+
}
|
|
588
|
+
.meta-chip {
|
|
589
|
+
font-family: var(--font-mono);
|
|
590
|
+
font-size: 13px;
|
|
591
|
+
color: var(--text-dim);
|
|
592
|
+
background: var(--bg-card);
|
|
593
|
+
border: 1px solid var(--border);
|
|
594
|
+
padding: 3px 10px;
|
|
595
|
+
border-radius: 4px;
|
|
596
|
+
white-space: nowrap;
|
|
597
|
+
}
|
|
598
|
+
|
|
599
|
+
/* \u2500\u2500\u2500 DATA GRID \u2500\u2500\u2500 */
|
|
600
|
+
.wrap {
|
|
601
|
+
overflow: auto;
|
|
602
|
+
flex: 1;
|
|
603
|
+
background: var(--bg);
|
|
604
|
+
position: relative;
|
|
605
|
+
}
|
|
606
|
+
|
|
607
|
+
table.data-table {
|
|
608
|
+
border-collapse: separate;
|
|
609
|
+
border-spacing: 0;
|
|
610
|
+
width: max-content;
|
|
611
|
+
min-width: 100%;
|
|
612
|
+
}
|
|
613
|
+
|
|
614
|
+
th, td {
|
|
615
|
+
border-bottom: 1px solid var(--border);
|
|
616
|
+
border-right: 1px solid var(--border);
|
|
617
|
+
padding: 13px 20px;
|
|
618
|
+
text-align: left;
|
|
619
|
+
vertical-align: middle;
|
|
620
|
+
max-width: 460px;
|
|
621
|
+
overflow: hidden;
|
|
622
|
+
text-overflow: ellipsis;
|
|
623
|
+
white-space: nowrap;
|
|
624
|
+
font-size: 14px;
|
|
625
|
+
line-height: 1.5;
|
|
626
|
+
}
|
|
627
|
+
|
|
628
|
+
th {
|
|
629
|
+
position: sticky;
|
|
630
|
+
top: 0;
|
|
631
|
+
background: var(--bg-card);
|
|
632
|
+
color: var(--text-dim);
|
|
633
|
+
font-family: var(--font-mono);
|
|
634
|
+
font-weight: 600;
|
|
635
|
+
font-size: 12.5px;
|
|
636
|
+
letter-spacing: .06em;
|
|
637
|
+
text-transform: uppercase;
|
|
638
|
+
z-index: 5;
|
|
639
|
+
cursor: pointer;
|
|
640
|
+
user-select: none;
|
|
641
|
+
transition: color .15s, background .15s;
|
|
642
|
+
padding: 12px 20px;
|
|
643
|
+
}
|
|
644
|
+
th:hover {
|
|
645
|
+
color: var(--accent);
|
|
646
|
+
background: var(--bg-raised);
|
|
647
|
+
}
|
|
648
|
+
th .th-content {
|
|
649
|
+
display: flex;
|
|
650
|
+
align-items: center;
|
|
651
|
+
justify-content: space-between;
|
|
652
|
+
gap: 8px;
|
|
653
|
+
}
|
|
654
|
+
th .sort-arrow {
|
|
655
|
+
color: var(--accent);
|
|
656
|
+
font-size: 11px;
|
|
657
|
+
}
|
|
658
|
+
|
|
659
|
+
td {
|
|
660
|
+
font-family: var(--font-mono);
|
|
661
|
+
background: var(--bg);
|
|
662
|
+
color: var(--text);
|
|
663
|
+
}
|
|
664
|
+
tr:hover td {
|
|
665
|
+
background: var(--bg-card);
|
|
666
|
+
}
|
|
667
|
+
|
|
668
|
+
/* Syntax colors from client/style.css */
|
|
669
|
+
td.cell-id { color: var(--purple); font-weight: 500; }
|
|
670
|
+
td.cell-number { color: var(--blue); }
|
|
671
|
+
td.cell-date { color: var(--orange); }
|
|
672
|
+
td.cell-bool-true { color: var(--green); }
|
|
673
|
+
td.cell-bool-false { color: var(--text-muted); }
|
|
674
|
+
td.cell-null { color: var(--text-muted); font-style: italic; }
|
|
675
|
+
td.cell-obj { color: var(--accent); cursor: pointer; }
|
|
676
|
+
td.cell-obj:hover { text-decoration: underline; color: var(--accent-2); }
|
|
677
|
+
|
|
678
|
+
td.num-col, th.num-col {
|
|
679
|
+
width: 52px;
|
|
680
|
+
min-width: 52px;
|
|
681
|
+
max-width: 52px;
|
|
682
|
+
text-align: center;
|
|
683
|
+
position: sticky;
|
|
684
|
+
left: 0;
|
|
685
|
+
z-index: 3;
|
|
686
|
+
border-right: 1px solid var(--border);
|
|
687
|
+
color: var(--text-muted);
|
|
688
|
+
font-family: var(--font-mono);
|
|
689
|
+
font-size: 12px;
|
|
690
|
+
user-select: none;
|
|
691
|
+
}
|
|
692
|
+
th.num-col { z-index: 7; background: var(--bg-card); cursor: default; }
|
|
693
|
+
td.num-col { background: var(--bg-card); }
|
|
694
|
+
tr:hover td.num-col { background: var(--bg-raised); color: var(--accent); }
|
|
695
|
+
|
|
696
|
+
td.act-col, th.act-col {
|
|
697
|
+
width: 100px;
|
|
698
|
+
min-width: 100px;
|
|
699
|
+
max-width: 100px;
|
|
700
|
+
text-align: center;
|
|
701
|
+
position: sticky;
|
|
702
|
+
left: 52px;
|
|
703
|
+
z-index: 2;
|
|
704
|
+
border-right: 2px solid var(--border);
|
|
705
|
+
}
|
|
706
|
+
th.act-col { z-index: 6; background: var(--bg-card); cursor: default; }
|
|
707
|
+
td.act-col { background: var(--bg-card); }
|
|
708
|
+
tr:hover td.act-col { background: var(--bg-raised); }
|
|
709
|
+
|
|
710
|
+
tr.ghost-row td {
|
|
711
|
+
background: transparent !important;
|
|
712
|
+
border-bottom: 1px solid rgba(29, 33, 39, .6);
|
|
713
|
+
border-right: 1px solid rgba(29, 33, 39, .6);
|
|
714
|
+
pointer-events: none;
|
|
715
|
+
user-select: none;
|
|
716
|
+
height: 46px;
|
|
717
|
+
}
|
|
718
|
+
tr.ghost-row td.num-col {
|
|
719
|
+
background: rgba(14, 16, 20, .3) !important;
|
|
720
|
+
}
|
|
721
|
+
|
|
722
|
+
.row-actions {
|
|
723
|
+
display: flex;
|
|
724
|
+
align-items: center;
|
|
725
|
+
justify-content: center;
|
|
726
|
+
gap: 6px;
|
|
727
|
+
}
|
|
728
|
+
.row-act-btn {
|
|
729
|
+
background: none;
|
|
730
|
+
border: 0;
|
|
731
|
+
color: var(--text-dim);
|
|
732
|
+
cursor: pointer;
|
|
733
|
+
padding: 6px;
|
|
734
|
+
border-radius: 4px;
|
|
735
|
+
display: flex;
|
|
736
|
+
align-items: center;
|
|
737
|
+
transition: color .15s, background .15s;
|
|
738
|
+
}
|
|
739
|
+
.row-act-btn svg { width: 15px; height: 15px; }
|
|
740
|
+
.row-act-btn:hover { background: var(--border-lit); color: var(--text); }
|
|
741
|
+
.row-act-btn.edit:hover { color: var(--accent); }
|
|
742
|
+
.row-act-btn.del:hover { color: var(--red); }
|
|
743
|
+
|
|
744
|
+
/* \u2500\u2500\u2500 STRUCTURE CARDS \u2500\u2500\u2500 */
|
|
745
|
+
.structure-wrap {
|
|
746
|
+
padding: 28px;
|
|
747
|
+
max-width: 1100px;
|
|
748
|
+
}
|
|
749
|
+
.window-card {
|
|
750
|
+
background: var(--bg-card);
|
|
751
|
+
border: 1px solid var(--border);
|
|
752
|
+
border-radius: var(--radius-lg);
|
|
753
|
+
overflow: hidden;
|
|
754
|
+
margin-bottom: 24px;
|
|
755
|
+
box-shadow: 0 16px 40px rgba(0,0,0,.45);
|
|
756
|
+
}
|
|
757
|
+
.code-bar {
|
|
758
|
+
display: flex;
|
|
759
|
+
align-items: center;
|
|
760
|
+
gap: 8px;
|
|
761
|
+
padding: 12px 18px;
|
|
762
|
+
border-bottom: 1px solid var(--border);
|
|
763
|
+
background: var(--bg-raised);
|
|
764
|
+
}
|
|
765
|
+
.dot { width: 10px; height: 10px; border-radius: 50%; }
|
|
766
|
+
.dot.r { background: #ff5f57; }
|
|
767
|
+
.dot.y { background: #febc2e; }
|
|
768
|
+
.dot.g { background: #28c840; }
|
|
769
|
+
.code-bar-label {
|
|
770
|
+
font-family: var(--font-mono);
|
|
771
|
+
font-size: 13px;
|
|
772
|
+
font-weight: 500;
|
|
773
|
+
color: var(--text-dim);
|
|
774
|
+
margin-left: 6px;
|
|
775
|
+
}
|
|
776
|
+
.type-tag {
|
|
777
|
+
font-family: var(--font-mono);
|
|
778
|
+
font-size: 12.5px;
|
|
779
|
+
color: var(--blue);
|
|
780
|
+
background: rgba(124,182,242,.12);
|
|
781
|
+
border: 1px solid rgba(124,182,242,.28);
|
|
782
|
+
padding: 3px 8px;
|
|
783
|
+
border-radius: 4px;
|
|
784
|
+
}
|
|
785
|
+
.null-tag {
|
|
786
|
+
font-family: var(--font-mono);
|
|
787
|
+
font-size: 12.5px;
|
|
788
|
+
padding: 3px 8px;
|
|
789
|
+
border-radius: 4px;
|
|
790
|
+
}
|
|
791
|
+
.null-tag.not-null { color: var(--green); background: rgba(140,196,159,.12); border: 1px solid rgba(140,196,159,.28); }
|
|
792
|
+
.null-tag.nullable { color: var(--text-muted); background: var(--bg-raised); border: 1px solid var(--border); }
|
|
793
|
+
|
|
794
|
+
/* Empty state */
|
|
795
|
+
.empty-state {
|
|
796
|
+
display: flex;
|
|
797
|
+
flex-direction: column;
|
|
798
|
+
align-items: center;
|
|
799
|
+
justify-content: center;
|
|
800
|
+
padding: 96px 20px;
|
|
801
|
+
color: var(--text-dim);
|
|
802
|
+
text-align: center;
|
|
803
|
+
}
|
|
804
|
+
.empty-state svg {
|
|
805
|
+
color: var(--accent);
|
|
806
|
+
opacity: .7;
|
|
807
|
+
margin-bottom: 16px;
|
|
808
|
+
}
|
|
809
|
+
.empty-state h3 {
|
|
810
|
+
font-size: 1.25rem;
|
|
811
|
+
font-weight: 600;
|
|
812
|
+
color: var(--text);
|
|
813
|
+
margin-bottom: 8px;
|
|
814
|
+
}
|
|
815
|
+
.empty-state p {
|
|
816
|
+
color: var(--text-dim);
|
|
817
|
+
font-size: 15px;
|
|
818
|
+
}
|
|
819
|
+
|
|
820
|
+
/* \u2500\u2500\u2500 MODALS \u2500\u2500\u2500 */
|
|
821
|
+
.modal-overlay {
|
|
822
|
+
position: fixed;
|
|
823
|
+
inset: 0;
|
|
824
|
+
background: rgba(8, 9, 11, .85);
|
|
825
|
+
backdrop-filter: blur(8px);
|
|
826
|
+
-webkit-backdrop-filter: blur(8px);
|
|
827
|
+
display: none;
|
|
828
|
+
align-items: center;
|
|
829
|
+
justify-content: center;
|
|
830
|
+
z-index: 100;
|
|
831
|
+
}
|
|
832
|
+
.modal-overlay.on { display: flex; }
|
|
833
|
+
|
|
834
|
+
.modal-window {
|
|
835
|
+
background: var(--bg-card);
|
|
836
|
+
border: 1px solid var(--border-lit);
|
|
837
|
+
border-radius: var(--radius-lg);
|
|
838
|
+
width: min(780px, 94vw);
|
|
839
|
+
max-height: 88vh;
|
|
840
|
+
display: flex;
|
|
841
|
+
flex-direction: column;
|
|
842
|
+
box-shadow: 0 24px 80px rgba(0,0,0,.7), 0 0 0 1px var(--border);
|
|
843
|
+
overflow: hidden;
|
|
844
|
+
animation: modalIn .2s var(--ease-out);
|
|
845
|
+
}
|
|
846
|
+
@keyframes modalIn {
|
|
847
|
+
from { opacity: 0; transform: translateY(12px) scale(.98); }
|
|
848
|
+
to { opacity: 1; transform: none; }
|
|
849
|
+
}
|
|
850
|
+
|
|
851
|
+
.modal-header {
|
|
852
|
+
padding: 14px 22px;
|
|
853
|
+
background: var(--bg-raised);
|
|
854
|
+
border-bottom: 1px solid var(--border);
|
|
855
|
+
display: flex;
|
|
856
|
+
align-items: center;
|
|
857
|
+
justify-content: space-between;
|
|
858
|
+
}
|
|
859
|
+
.modal-header h3 {
|
|
860
|
+
font-family: var(--font-mono);
|
|
861
|
+
font-size: 16px;
|
|
862
|
+
font-weight: 600;
|
|
863
|
+
color: var(--text);
|
|
864
|
+
margin: 0;
|
|
865
|
+
}
|
|
866
|
+
.modal-close {
|
|
867
|
+
background: none;
|
|
868
|
+
border: 0;
|
|
869
|
+
color: var(--text-dim);
|
|
870
|
+
font-size: 20px;
|
|
871
|
+
cursor: pointer;
|
|
872
|
+
}
|
|
873
|
+
.modal-close:hover { color: var(--text); }
|
|
874
|
+
|
|
875
|
+
.modal-tabs {
|
|
876
|
+
display: flex;
|
|
877
|
+
background: var(--bg-card);
|
|
878
|
+
border-bottom: 1px solid var(--border);
|
|
879
|
+
padding: 0 16px;
|
|
880
|
+
}
|
|
881
|
+
.modal-tab-btn {
|
|
882
|
+
background: none;
|
|
883
|
+
border: 0;
|
|
884
|
+
border-bottom: 2px solid transparent;
|
|
885
|
+
padding: 11px 20px;
|
|
886
|
+
font-family: var(--font-mono);
|
|
887
|
+
font-size: 14px;
|
|
888
|
+
color: var(--text-dim);
|
|
889
|
+
cursor: pointer;
|
|
890
|
+
transition: color .15s;
|
|
891
|
+
}
|
|
892
|
+
.modal-tab-btn:hover { color: var(--text); }
|
|
893
|
+
.modal-tab-btn.active {
|
|
894
|
+
color: var(--accent);
|
|
895
|
+
border-bottom-color: var(--accent);
|
|
896
|
+
font-weight: 500;
|
|
897
|
+
}
|
|
898
|
+
|
|
899
|
+
.modal-body {
|
|
900
|
+
padding: 24px;
|
|
901
|
+
overflow-y: auto;
|
|
902
|
+
flex: 1;
|
|
903
|
+
}
|
|
904
|
+
|
|
905
|
+
.form-grid {
|
|
906
|
+
display: grid;
|
|
907
|
+
grid-template-columns: 160px 1fr;
|
|
908
|
+
gap: 16px 22px;
|
|
909
|
+
align-items: center;
|
|
910
|
+
}
|
|
911
|
+
.form-label {
|
|
912
|
+
font-family: var(--font-mono);
|
|
913
|
+
font-size: 13.5px;
|
|
914
|
+
color: var(--text-dim);
|
|
915
|
+
word-break: break-all;
|
|
916
|
+
}
|
|
917
|
+
.form-input {
|
|
918
|
+
width: 100%;
|
|
919
|
+
background: var(--bg-raised);
|
|
920
|
+
border: 1px solid var(--border-lit);
|
|
921
|
+
border-radius: var(--r);
|
|
922
|
+
padding: 9px 14px;
|
|
923
|
+
color: var(--text);
|
|
924
|
+
font-family: var(--font-mono);
|
|
925
|
+
font-size: 14px;
|
|
926
|
+
outline: none;
|
|
927
|
+
transition: border-color .15s, box-shadow .15s;
|
|
928
|
+
}
|
|
929
|
+
.form-input:focus {
|
|
930
|
+
border-color: var(--accent);
|
|
931
|
+
box-shadow: 0 0 0 1px var(--accent-glow);
|
|
932
|
+
}
|
|
933
|
+
|
|
934
|
+
.json-textarea {
|
|
935
|
+
width: 100%;
|
|
936
|
+
height: 320px;
|
|
937
|
+
background: var(--bg-raised);
|
|
938
|
+
border: 1px solid var(--border-lit);
|
|
939
|
+
border-radius: var(--r);
|
|
940
|
+
color: var(--text);
|
|
941
|
+
font-family: var(--font-mono);
|
|
942
|
+
font-size: 13.5px;
|
|
943
|
+
line-height: 1.6;
|
|
944
|
+
padding: 16px;
|
|
945
|
+
outline: none;
|
|
946
|
+
resize: vertical;
|
|
947
|
+
}
|
|
948
|
+
.json-textarea:focus {
|
|
949
|
+
border-color: var(--accent);
|
|
950
|
+
box-shadow: 0 0 0 1px var(--accent-glow);
|
|
951
|
+
}
|
|
952
|
+
|
|
953
|
+
.modal-err {
|
|
954
|
+
margin-top: 14px;
|
|
955
|
+
padding: 11px 16px;
|
|
956
|
+
border-radius: var(--r);
|
|
957
|
+
background: rgba(240,122,114,.12);
|
|
958
|
+
border: 1px solid rgba(240,122,114,.35);
|
|
959
|
+
color: var(--red);
|
|
960
|
+
font-family: var(--font-mono);
|
|
961
|
+
font-size: 13px;
|
|
962
|
+
white-space: pre-wrap;
|
|
963
|
+
display: none;
|
|
964
|
+
}
|
|
965
|
+
.modal-err.on { display: block; }
|
|
966
|
+
|
|
967
|
+
.modal-footer {
|
|
968
|
+
padding: 16px 22px;
|
|
969
|
+
border-top: 1px solid var(--border);
|
|
970
|
+
background: var(--bg-raised);
|
|
971
|
+
display: flex;
|
|
972
|
+
align-items: center;
|
|
973
|
+
justify-content: space-between;
|
|
974
|
+
}
|
|
975
|
+
.modal-footer-right {
|
|
976
|
+
display: flex;
|
|
977
|
+
gap: 12px;
|
|
978
|
+
}
|
|
979
|
+
|
|
980
|
+
/* \u2500\u2500\u2500 STATUS BAR \u2500\u2500\u2500 */
|
|
981
|
+
.statusbar {
|
|
982
|
+
flex-shrink: 0;
|
|
983
|
+
height: 30px;
|
|
984
|
+
display: flex;
|
|
985
|
+
align-items: center;
|
|
986
|
+
justify-content: space-between;
|
|
987
|
+
padding: 0 20px;
|
|
988
|
+
background: var(--bg-card);
|
|
989
|
+
border-top: 1px solid var(--border);
|
|
990
|
+
color: var(--text-dim);
|
|
991
|
+
font-family: var(--font-mono);
|
|
992
|
+
font-size: 12.5px;
|
|
993
|
+
position: relative;
|
|
994
|
+
z-index: 10;
|
|
995
|
+
}
|
|
996
|
+
.sb-left, .sb-right, .sb-center {
|
|
997
|
+
display: flex;
|
|
998
|
+
align-items: center;
|
|
999
|
+
gap: 18px;
|
|
1000
|
+
}
|
|
1001
|
+
.sb-item {
|
|
1002
|
+
display: flex;
|
|
1003
|
+
align-items: center;
|
|
1004
|
+
gap: 6px;
|
|
1005
|
+
white-space: nowrap;
|
|
1006
|
+
}
|
|
1007
|
+
.sb-dot {
|
|
1008
|
+
width: 7px;
|
|
1009
|
+
height: 7px;
|
|
1010
|
+
border-radius: 50%;
|
|
1011
|
+
background: var(--green);
|
|
1012
|
+
box-shadow: 0 0 6px rgba(140,196,159,.5);
|
|
1013
|
+
}
|
|
1014
|
+
.sb-hint {
|
|
1015
|
+
color: var(--text-muted);
|
|
1016
|
+
font-size: 12px;
|
|
1017
|
+
}
|
|
1018
|
+
|
|
1019
|
+
/* Toast */
|
|
1020
|
+
.toast-wrap {
|
|
1021
|
+
position: fixed;
|
|
1022
|
+
bottom: 38px;
|
|
1023
|
+
right: 24px;
|
|
1024
|
+
display: flex;
|
|
1025
|
+
flex-direction: column;
|
|
1026
|
+
gap: 8px;
|
|
1027
|
+
z-index: 200;
|
|
1028
|
+
pointer-events: none;
|
|
1029
|
+
}
|
|
1030
|
+
.toast {
|
|
1031
|
+
background: var(--bg-card);
|
|
1032
|
+
border: 1px solid var(--border-lit);
|
|
1033
|
+
color: var(--text);
|
|
1034
|
+
padding: 10px 18px;
|
|
1035
|
+
border-radius: var(--r);
|
|
1036
|
+
font-size: 13.5px;
|
|
1037
|
+
box-shadow: 0 8px 24px rgba(0,0,0,.6);
|
|
1038
|
+
display: flex;
|
|
1039
|
+
align-items: center;
|
|
1040
|
+
gap: 8px;
|
|
1041
|
+
animation: toastIn .2s var(--ease-out);
|
|
1042
|
+
}
|
|
1043
|
+
.toast::before {
|
|
1044
|
+
content: '';
|
|
1045
|
+
width: 6px;
|
|
1046
|
+
height: 6px;
|
|
1047
|
+
border-radius: 50%;
|
|
1048
|
+
background: var(--accent);
|
|
1049
|
+
}
|
|
1050
|
+
@keyframes toastIn {
|
|
1051
|
+
from { opacity: 0; transform: translateY(10px); }
|
|
1052
|
+
to { opacity: 1; transform: none; }
|
|
1053
|
+
}
|
|
1054
|
+
</style>
|
|
1055
|
+
</head>
|
|
1056
|
+
<body>
|
|
1057
|
+
|
|
1058
|
+
<!-- TOP BAR (Full width across top so badges never clip) -->
|
|
1059
|
+
<header class="ws-topbar">
|
|
1060
|
+
<div class="logo">
|
|
1061
|
+
<svg class="logo-img" viewBox="0 0 32 32" fill="none" aria-hidden="true">
|
|
1062
|
+
<rect x="6" y="7" width="20" height="3" rx="1.5" fill="currentColor" />
|
|
1063
|
+
<rect x="6" y="14.5" width="14" height="3" rx="1.5" fill="currentColor" opacity="0.85" />
|
|
1064
|
+
<rect x="6" y="22" width="20" height="3" rx="1.5" fill="currentColor" />
|
|
1065
|
+
</svg>
|
|
1066
|
+
<span>efc<span class="logo-dot">.</span>studio</span>
|
|
1067
|
+
</div>
|
|
1068
|
+
<span class="ws-topbar-label">Studio</span>
|
|
1069
|
+
<div class="badge-group">
|
|
1070
|
+
<span class="badge-engine" id="engineBadge">db</span>
|
|
1071
|
+
<span class="badge-mode ro" id="modeBadge">read-only</span>
|
|
1072
|
+
</div>
|
|
1073
|
+
|
|
1074
|
+
<div class="topbar-spacer"></div>
|
|
1075
|
+
|
|
1076
|
+
<div class="header-center" id="rowSearchWrap">
|
|
1077
|
+
<div class="input-search-wrap" style="width: 240px;">
|
|
1078
|
+
<svg width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
|
|
1079
|
+
<circle cx="11" cy="11" r="8"></circle>
|
|
1080
|
+
<line x1="21" y1="21" x2="16.65" y2="16.65"></line>
|
|
1081
|
+
</svg>
|
|
1082
|
+
<input type="text" id="rowSearch" class="input-search" placeholder="Filter rows in view..." autocomplete="off" disabled>
|
|
1083
|
+
<button id="rowSearchClear" class="clear-btn" hidden title="Clear filter">×</button>
|
|
1084
|
+
</div>
|
|
1085
|
+
</div>
|
|
1086
|
+
|
|
1087
|
+
<div class="tabbar">
|
|
1088
|
+
<button id="btnModeRows" class="tab-item active" title="View data rows">
|
|
1089
|
+
<svg width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
|
|
1090
|
+
<line x1="8" y1="6" x2="21" y2="6"></line>
|
|
1091
|
+
<line x1="8" y1="12" x2="21" y2="12"></line>
|
|
1092
|
+
<line x1="8" y1="18" x2="21" y2="18"></line>
|
|
1093
|
+
<line x1="3" y1="6" x2="3.01" y2="6"></line>
|
|
1094
|
+
<line x1="3" y1="12" x2="3.01" y2="12"></line>
|
|
1095
|
+
<line x1="3" y1="18" x2="3.01" y2="18"></line>
|
|
1096
|
+
</svg>
|
|
1097
|
+
Rows
|
|
1098
|
+
</button>
|
|
1099
|
+
<button id="btnModeStructure" class="tab-item" title="View schema structure" disabled>
|
|
1100
|
+
<svg width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
|
|
1101
|
+
<rect x="3" y="3" width="18" height="18" rx="2" ry="2"></rect>
|
|
1102
|
+
<line x1="3" y1="9" x2="21" y2="9"></line>
|
|
1103
|
+
<line x1="9" y1="21" x2="9" y2="9"></line>
|
|
1104
|
+
</svg>
|
|
1105
|
+
Structure
|
|
1106
|
+
</button>
|
|
1107
|
+
</div>
|
|
1108
|
+
|
|
1109
|
+
<button id="btnRefresh" class="btn-ghost btn-icon" title="Refresh data" disabled>
|
|
1110
|
+
<svg width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
|
|
1111
|
+
<path d="M23 4v6h-6"></path>
|
|
1112
|
+
<path d="M1 20v-6h6"></path>
|
|
1113
|
+
<path d="M3.51 9a9 9 0 0 1 14.85-3.36L23 10M1 14l4.64 4.36A9 9 0 0 0 20.49 15"></path>
|
|
1114
|
+
</svg>
|
|
1115
|
+
</button>
|
|
1116
|
+
|
|
1117
|
+
<div class="btn-group">
|
|
1118
|
+
<button id="prev" class="btn-ghost btn-icon" disabled title="Previous page">
|
|
1119
|
+
<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
|
|
1120
|
+
<polyline points="15 18 9 12 15 6"></polyline>
|
|
1121
|
+
</svg>
|
|
1122
|
+
</button>
|
|
1123
|
+
<button id="next" class="btn-ghost btn-icon" disabled title="Next page">
|
|
1124
|
+
<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
|
|
1125
|
+
<polyline points="9 18 15 12 9 6"></polyline>
|
|
1126
|
+
</svg>
|
|
1127
|
+
</button>
|
|
1128
|
+
</div>
|
|
1129
|
+
|
|
1130
|
+
<button id="ins" class="btn-primary" hidden>
|
|
1131
|
+
<svg width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
|
|
1132
|
+
<line x1="12" y1="5" x2="12" y2="19"></line>
|
|
1133
|
+
<line x1="5" y1="12" x2="19" y2="12"></line>
|
|
1134
|
+
</svg>
|
|
1135
|
+
+ Insert
|
|
1136
|
+
</button>
|
|
1137
|
+
</header>
|
|
1138
|
+
|
|
1139
|
+
<div class="ws-body">
|
|
1140
|
+
<aside>
|
|
1141
|
+
<div class="search-box">
|
|
1142
|
+
<div class="input-search-wrap">
|
|
1143
|
+
<svg width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
|
|
1144
|
+
<circle cx="11" cy="11" r="8"></circle>
|
|
1145
|
+
<line x1="21" y1="21" x2="16.65" y2="16.65"></line>
|
|
1146
|
+
</svg>
|
|
1147
|
+
<input type="text" id="tableSearch" class="input-search" placeholder="Search tables..." autocomplete="off">
|
|
1148
|
+
<button id="tableSearchClear" class="clear-btn" hidden title="Clear search">×</button>
|
|
1149
|
+
</div>
|
|
1150
|
+
</div>
|
|
1151
|
+
|
|
1152
|
+
<div class="sidebar-header">
|
|
1153
|
+
<span>Collections</span>
|
|
1154
|
+
<span id="tableCountBadge"></span>
|
|
1155
|
+
</div>
|
|
1156
|
+
|
|
1157
|
+
<div id="list" class="table-tree"></div>
|
|
1158
|
+
</aside>
|
|
1159
|
+
|
|
1160
|
+
<main>
|
|
1161
|
+
<div class="workspace-bar">
|
|
1162
|
+
<svg class="ico-table" width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round">
|
|
1163
|
+
<rect x="3" y="3" width="18" height="18" rx="2"></rect>
|
|
1164
|
+
<line x1="3" y1="9" x2="21" y2="9"></line>
|
|
1165
|
+
<line x1="9" y1="21" x2="9" y2="9"></line>
|
|
1166
|
+
</svg>
|
|
1167
|
+
<h2 id="title" class="active-title">Select a table</h2>
|
|
1168
|
+
<span id="meta" class="meta-chip">empty</span>
|
|
1169
|
+
</div>
|
|
1170
|
+
|
|
1171
|
+
<div class="wrap" id="grid">
|
|
1172
|
+
<div class="empty-state">
|
|
1173
|
+
<svg width="48" height="48" viewBox="0 0 32 32" fill="none" aria-hidden="true">
|
|
1174
|
+
<rect x="6" y="7" width="20" height="3" rx="1.5" fill="currentColor" />
|
|
1175
|
+
<rect x="6" y="14.5" width="14" height="3" rx="1.5" fill="currentColor" opacity="0.85" />
|
|
1176
|
+
<rect x="6" y="22" width="20" height="3" rx="1.5" fill="currentColor" />
|
|
1177
|
+
</svg>
|
|
1178
|
+
<h3>Select a collection</h3>
|
|
1179
|
+
<p>Choose any table or collection from the left sidebar to inspect and edit records.</p>
|
|
1180
|
+
</div>
|
|
1181
|
+
</div>
|
|
1182
|
+
</main>
|
|
1183
|
+
</div>
|
|
1184
|
+
|
|
1185
|
+
<footer class="statusbar">
|
|
1186
|
+
<div class="sb-left">
|
|
1187
|
+
<div class="sb-item">
|
|
1188
|
+
<span class="sb-dot on"></span>
|
|
1189
|
+
<span id="sbEngine">Database</span>
|
|
1190
|
+
</div>
|
|
1191
|
+
<div class="sb-item">
|
|
1192
|
+
<span id="sbTable">\u2014</span>
|
|
1193
|
+
</div>
|
|
1194
|
+
</div>
|
|
1195
|
+
<div class="sb-center">
|
|
1196
|
+
<span class="sb-hint">Double-click row to inspect/edit \xB7 Filter: / \xB7 Next/Prev: \u2190 / \u2192</span>
|
|
1197
|
+
</div>
|
|
1198
|
+
<div class="sb-right">
|
|
1199
|
+
<div class="sb-item">
|
|
1200
|
+
<span id="sbCount">0 records</span>
|
|
1201
|
+
</div>
|
|
1202
|
+
<div class="sb-item">
|
|
1203
|
+
<span id="sbMode">read-only</span>
|
|
1204
|
+
</div>
|
|
1205
|
+
</div>
|
|
1206
|
+
</footer>
|
|
1207
|
+
|
|
1208
|
+
<!-- Editor Modal -->
|
|
1209
|
+
<div id="ed" class="modal-overlay">
|
|
1210
|
+
<div class="modal-window">
|
|
1211
|
+
<div class="modal-header">
|
|
1212
|
+
<h3 id="edTitle">Edit record</h3>
|
|
1213
|
+
<button id="edClose" class="modal-close" title="Close (Esc)">×</button>
|
|
1214
|
+
</div>
|
|
1215
|
+
<div class="modal-tabs">
|
|
1216
|
+
<button id="edTabForm" class="modal-tab-btn active">Form</button>
|
|
1217
|
+
<button id="edTabJson" class="modal-tab-btn">JSON</button>
|
|
1218
|
+
</div>
|
|
1219
|
+
<div class="modal-body">
|
|
1220
|
+
<div id="edFormPanel">
|
|
1221
|
+
<div id="edFormFields" class="form-grid"></div>
|
|
1222
|
+
</div>
|
|
1223
|
+
<div id="edJsonPanel" style="display:none">
|
|
1224
|
+
<textarea id="edText" class="json-textarea" spellcheck="false"></textarea>
|
|
1225
|
+
</div>
|
|
1226
|
+
<div id="edErr" class="modal-err"></div>
|
|
1227
|
+
</div>
|
|
1228
|
+
<div class="modal-footer">
|
|
1229
|
+
<button id="edDel" class="btn-danger">Delete</button>
|
|
1230
|
+
<div class="modal-footer-right">
|
|
1231
|
+
<button id="edCancel" class="btn-ghost">Cancel</button>
|
|
1232
|
+
<button id="edSave" class="btn-primary">Save Changes</button>
|
|
1233
|
+
</div>
|
|
1234
|
+
</div>
|
|
1235
|
+
</div>
|
|
1236
|
+
</div>
|
|
1237
|
+
|
|
1238
|
+
<!-- Value Inspector Modal -->
|
|
1239
|
+
<div id="jsonModal" class="modal-overlay">
|
|
1240
|
+
<div class="modal-window" style="width: min(600px, 94vw);">
|
|
1241
|
+
<div class="modal-header">
|
|
1242
|
+
<h3 id="jsonModalTitle">Inspect Value</h3>
|
|
1243
|
+
<button id="jsonModalClose" class="modal-close">×</button>
|
|
1244
|
+
</div>
|
|
1245
|
+
<div class="modal-body">
|
|
1246
|
+
<pre id="jsonModalPre" style="margin:0; font-family:var(--font-mono); font-size:.8rem; line-height:1.6; white-space:pre-wrap; color:var(--text);"></pre>
|
|
1247
|
+
</div>
|
|
1248
|
+
<div class="modal-footer" style="justify-content: flex-end;">
|
|
1249
|
+
<button id="jsonModalCopy" class="btn-ghost">Copy JSON</button>
|
|
1250
|
+
</div>
|
|
1251
|
+
</div>
|
|
1252
|
+
</div>
|
|
1253
|
+
|
|
1254
|
+
<div class="toast-wrap" id="toasts"></div>
|
|
1255
|
+
|
|
1256
|
+
<script>
|
|
1257
|
+
const TOKEN=__EFC_TOKEN__;
|
|
1258
|
+
const LIMIT=50;
|
|
1259
|
+
let cur=null,skip=0,mode='rows',write=false,writable=new Set(),editing=null;
|
|
1260
|
+
let allCollections=[];
|
|
1261
|
+
let currentRows=[];
|
|
1262
|
+
let activeColumns=[];
|
|
1263
|
+
let sortCol=null,sortAsc=true;
|
|
1264
|
+
const SKIP=new Set(['_id','id','__v','createdAt','updatedAt']);
|
|
1265
|
+
|
|
1266
|
+
const esc=s=>String(s).replace(/[&<>"]/g,c=>({'&':'&','<':'<','>':'>','"':'"'}[c]));
|
|
1267
|
+
|
|
1268
|
+
function toast(msg){
|
|
1269
|
+
const el=document.createElement('div');
|
|
1270
|
+
el.className='toast';
|
|
1271
|
+
el.textContent=msg;
|
|
1272
|
+
document.getElementById('toasts').appendChild(el);
|
|
1273
|
+
setTimeout(()=>el.remove(),2500);
|
|
1274
|
+
}
|
|
1275
|
+
|
|
1276
|
+
async function api(p){
|
|
1277
|
+
const r=await fetch(p);
|
|
1278
|
+
if(!r.ok){
|
|
1279
|
+
const d=await r.json().catch(()=>({}));
|
|
1280
|
+
throw new Error(d.error||r.statusText);
|
|
1281
|
+
}
|
|
1282
|
+
return r.json();
|
|
1283
|
+
}
|
|
1284
|
+
|
|
1285
|
+
async function send(method,p,body){
|
|
1286
|
+
const r=await fetch(p,{
|
|
1287
|
+
method,
|
|
1288
|
+
headers:{
|
|
1289
|
+
'Content-Type':'application/json',
|
|
1290
|
+
'X-EFC-Studio-Token':TOKEN
|
|
1291
|
+
},
|
|
1292
|
+
body:body===undefined?undefined:JSON.stringify(body)
|
|
1293
|
+
});
|
|
1294
|
+
const d=await r.json().catch(()=>({}));
|
|
1295
|
+
if(!r.ok){
|
|
1296
|
+
const e=new Error(d.error||r.statusText);
|
|
1297
|
+
e.issues=d.issues;
|
|
1298
|
+
throw e;
|
|
1299
|
+
}
|
|
1300
|
+
return d;
|
|
1301
|
+
}
|
|
1302
|
+
|
|
1303
|
+
function selectTable(name){
|
|
1304
|
+
cur=name;
|
|
1305
|
+
skip=0;
|
|
1306
|
+
sortCol=null;
|
|
1307
|
+
location.hash='#'+encodeURIComponent(name);
|
|
1308
|
+
document.querySelectorAll('.tree-row').forEach(x=>{
|
|
1309
|
+
const on=x.dataset.name===name;
|
|
1310
|
+
x.classList.toggle('active', on);
|
|
1311
|
+
if(on) x.scrollIntoView({ block: 'nearest' });
|
|
1312
|
+
});
|
|
1313
|
+
document.getElementById('btnModeStructure').disabled=false;
|
|
1314
|
+
document.getElementById('btnRefresh').disabled=false;
|
|
1315
|
+
document.getElementById('rowSearch').disabled=false;
|
|
1316
|
+
show();
|
|
1317
|
+
}
|
|
1318
|
+
|
|
1319
|
+
function renderTableList(filterText=''){
|
|
1320
|
+
const el=document.getElementById('list');
|
|
1321
|
+
el.innerHTML='';
|
|
1322
|
+
const q=filterText.toLowerCase().trim();
|
|
1323
|
+
const filtered=allCollections.filter(c=>!q||c.name.toLowerCase().includes(q));
|
|
1324
|
+
document.getElementById('tableCountBadge').textContent=filtered.length===allCollections.length?String(allCollections.length):filtered.length+' / '+allCollections.length;
|
|
1325
|
+
|
|
1326
|
+
if(!filtered.length){
|
|
1327
|
+
el.innerHTML='<div style="padding:24px 16px; color:var(--text-dim); text-align:center;">No collections match "'+esc(filterText)+'"</div>';
|
|
1328
|
+
return;
|
|
1329
|
+
}
|
|
1330
|
+
|
|
1331
|
+
for(const c of filtered){
|
|
1332
|
+
const b=document.createElement('div');
|
|
1333
|
+
b.className='tree-row'+(cur===c.name?' active':'');
|
|
1334
|
+
b.dataset.name=c.name;
|
|
1335
|
+
b.innerHTML='<div class="tree-left">'+
|
|
1336
|
+
'<svg class="ico-table" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round">'+
|
|
1337
|
+
'<rect x="3" y="3" width="18" height="18" rx="2"></rect><line x1="3" y1="9" x2="21" y2="9"></line><line x1="9" y1="21" x2="9" y2="9"></line></svg>'+
|
|
1338
|
+
'<span class="table-name" title="'+esc(c.name)+'">'+esc(c.name)+'</span></div>'+
|
|
1339
|
+
'<span class="count-badge">'+c.count+'</span>';
|
|
1340
|
+
b.onclick=()=>selectTable(c.name);
|
|
1341
|
+
el.appendChild(b);
|
|
1342
|
+
}
|
|
1343
|
+
}
|
|
1344
|
+
|
|
1345
|
+
async function loadList(){
|
|
1346
|
+
const d=await api('/api/collections');
|
|
1347
|
+
write=d.write;
|
|
1348
|
+
writable=new Set(d.collections.filter(c=>c.writable).map(c=>c.name));
|
|
1349
|
+
allCollections=d.collections;
|
|
1350
|
+
|
|
1351
|
+
const eng=document.getElementById('engineBadge');
|
|
1352
|
+
eng.textContent=d.engine;
|
|
1353
|
+
eng.className='badge-engine '+(d.engine==='postgresql'?'pg':'mongo');
|
|
1354
|
+
|
|
1355
|
+
const mb=document.getElementById('modeBadge');
|
|
1356
|
+
mb.textContent=write?'write':'read-only';
|
|
1357
|
+
mb.className='badge-mode '+(write?'write':'ro');
|
|
1358
|
+
|
|
1359
|
+
const sbEng=document.getElementById('sbEngine');
|
|
1360
|
+
if(sbEng) sbEng.textContent=d.engine==='postgresql'?'PostgreSQL':d.engine==='mongo'?'MongoDB':d.engine;
|
|
1361
|
+
const sbMd=document.getElementById('sbMode');
|
|
1362
|
+
if(sbMd) sbMd.textContent=write?'read-write':'read-only';
|
|
1363
|
+
|
|
1364
|
+
renderTableList(document.getElementById('tableSearch').value);
|
|
1365
|
+
if(!allCollections.length){
|
|
1366
|
+
document.getElementById('list').innerHTML='<div style="padding:24px 16px; color:var(--text-dim); text-align:center;">No collections found</div>';
|
|
1367
|
+
return;
|
|
1368
|
+
}
|
|
1369
|
+
|
|
1370
|
+
const hash=decodeURIComponent(location.hash.slice(1));
|
|
1371
|
+
const target=allCollections.find(c=>c.name===hash)||allCollections.find(c=>c.name==='studiobooks')||allCollections[0];
|
|
1372
|
+
if(target&&!cur){
|
|
1373
|
+
selectTable(target.name);
|
|
1374
|
+
}
|
|
1375
|
+
}
|
|
1376
|
+
|
|
1377
|
+
document.getElementById('tableSearch').oninput=(e)=>{
|
|
1378
|
+
const v=e.target.value;
|
|
1379
|
+
document.getElementById('tableSearchClear').hidden=!v;
|
|
1380
|
+
renderTableList(v);
|
|
1381
|
+
};
|
|
1382
|
+
document.getElementById('tableSearchClear').onclick=()=>{
|
|
1383
|
+
document.getElementById('tableSearch').value='';
|
|
1384
|
+
document.getElementById('tableSearchClear').hidden=true;
|
|
1385
|
+
renderTableList();
|
|
1386
|
+
};
|
|
1387
|
+
|
|
1388
|
+
function formatCell(val, key){
|
|
1389
|
+
if(val===null||val===undefined) return '<td class="cell-null">null</td>';
|
|
1390
|
+
if(typeof val==='boolean') return '<td class="'+(val?'cell-bool-true':'cell-bool-false')+'">'+val+'</td>';
|
|
1391
|
+
if(typeof val==='number') return '<td class="cell-number" title="'+val+'">'+val+'</td>';
|
|
1392
|
+
if(typeof val==='object'){
|
|
1393
|
+
const j=JSON.stringify(val);
|
|
1394
|
+
return '<td class="cell-obj" data-json="'+esc(j)+'" title="Click to inspect">'+esc(j)+'</td>';
|
|
1395
|
+
}
|
|
1396
|
+
const s=String(val);
|
|
1397
|
+
const isId=key==='id'||key==='_id'||/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(s);
|
|
1398
|
+
const isDate=/^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}/.test(s);
|
|
1399
|
+
const cls=isId?'cell-id':(isDate?'cell-date':'');
|
|
1400
|
+
return '<td class="'+cls+'" title="'+esc(s)+'">'+esc(s)+'</td>';
|
|
1401
|
+
}
|
|
1402
|
+
|
|
1403
|
+
function renderGrid(rows){
|
|
1404
|
+
const canWrite=writable.has(cur);
|
|
1405
|
+
const g=document.getElementById('grid');
|
|
1406
|
+
if(!rows.length){
|
|
1407
|
+
g.innerHTML='<div class="empty-state">'+
|
|
1408
|
+
'<svg width="40" height="40" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5"><circle cx="12" cy="12" r="10"></circle><line x1="8" y1="12" x2="16" y2="12"></line></svg>'+
|
|
1409
|
+
'<h3>No records found</h3><p>'+(currentRows.length?'No records match your filter in this view.':'This collection contains no data rows.')+'</p></div>';
|
|
1410
|
+
return;
|
|
1411
|
+
}
|
|
1412
|
+
|
|
1413
|
+
let h='<table class="data-table"><thead><tr>';
|
|
1414
|
+
h+='<th class="num-col">#</th>';
|
|
1415
|
+
if(canWrite) h+='<th class="act-col">Actions</th>';
|
|
1416
|
+
for(const c of activeColumns){
|
|
1417
|
+
const isSorted=sortCol===c;
|
|
1418
|
+
const arrow=isSorted?(sortAsc?'\u25B2':'\u25BC'):'';
|
|
1419
|
+
h+='<th data-col="'+esc(c)+'"><div class="th-content"><span>'+esc(c)+'</span><span class="sort-arrow">'+arrow+'</span></div></th>';
|
|
1420
|
+
}
|
|
1421
|
+
h+='</tr></thead><tbody>';
|
|
1422
|
+
|
|
1423
|
+
rows.forEach((r,i)=>{
|
|
1424
|
+
h+='<tr data-idx="'+i+'">';
|
|
1425
|
+
h+='<td class="num-col">'+(skip+i+1)+'</td>';
|
|
1426
|
+
if(canWrite){
|
|
1427
|
+
h+='<td class="act-col"><div class="row-actions">'+
|
|
1428
|
+
'<button class="row-act-btn edit" data-idx="'+i+'" title="Edit record">'+
|
|
1429
|
+
'<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M12 20h9"></path><path d="M16.5 3.5a2.121 2.121 0 0 1 3 3L7 19l-4 1 1-4L16.5 3.5z"></path></svg>'+
|
|
1430
|
+
'</button>'+
|
|
1431
|
+
'<button class="row-act-btn del" data-idx="'+i+'" title="Delete record">'+
|
|
1432
|
+
'<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="3 6 5 6 21 6"></polyline><path d="M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"></path></svg>'+
|
|
1433
|
+
'</button>'+
|
|
1434
|
+
'</div></td>';
|
|
1435
|
+
}
|
|
1436
|
+
for(const c of activeColumns){
|
|
1437
|
+
h+=formatCell(r[c], c);
|
|
1438
|
+
}
|
|
1439
|
+
h+='</tr>';
|
|
1440
|
+
});
|
|
1441
|
+
|
|
1442
|
+
const ghostCount=Math.max(0, 15 - rows.length);
|
|
1443
|
+
for(let g=0; g<ghostCount; g++){
|
|
1444
|
+
h+='<tr class="ghost-row"><td class="num-col"></td>';
|
|
1445
|
+
if(canWrite) h+='<td class="act-col"></td>';
|
|
1446
|
+
for(let c=0; c<activeColumns.length; c++){
|
|
1447
|
+
h+='<td></td>';
|
|
1448
|
+
}
|
|
1449
|
+
h+='</tr>';
|
|
1450
|
+
}
|
|
1451
|
+
|
|
1452
|
+
h+='</tbody></table>';
|
|
1453
|
+
g.innerHTML=h;
|
|
1454
|
+
|
|
1455
|
+
g.querySelectorAll('th[data-col]').forEach(th=>{
|
|
1456
|
+
th.onclick=()=>{
|
|
1457
|
+
const col=th.dataset.col;
|
|
1458
|
+
if(sortCol===col){
|
|
1459
|
+
if(sortAsc) sortAsc=false;
|
|
1460
|
+
else { sortCol=null; sortAsc=true; }
|
|
1461
|
+
} else {
|
|
1462
|
+
sortCol=col;
|
|
1463
|
+
sortAsc=true;
|
|
1464
|
+
}
|
|
1465
|
+
filterAndSortRows();
|
|
1466
|
+
};
|
|
1467
|
+
});
|
|
1468
|
+
|
|
1469
|
+
g.querySelectorAll('.row-act-btn.edit').forEach(b=>{
|
|
1470
|
+
b.onclick=()=>openEditor(rows[Number(b.dataset.idx)]);
|
|
1471
|
+
});
|
|
1472
|
+
|
|
1473
|
+
g.querySelectorAll('.row-act-btn.del').forEach(b=>{
|
|
1474
|
+
b.onclick=async()=>{
|
|
1475
|
+
const row=rows[Number(b.dataset.idx)];
|
|
1476
|
+
if(!confirm('Delete this record?')) return;
|
|
1477
|
+
try {
|
|
1478
|
+
await send('DELETE', '/api/collections/'+encodeURIComponent(cur)+'/'+encodeURIComponent(row.id??row._id));
|
|
1479
|
+
toast('Record deleted');
|
|
1480
|
+
await loadList();
|
|
1481
|
+
await loadRows();
|
|
1482
|
+
} catch(e) {
|
|
1483
|
+
alert(e.message);
|
|
1484
|
+
}
|
|
1485
|
+
};
|
|
1486
|
+
});
|
|
1487
|
+
|
|
1488
|
+
g.querySelectorAll('td.cell-obj').forEach(td=>{
|
|
1489
|
+
td.onclick=()=>{
|
|
1490
|
+
try {
|
|
1491
|
+
const val=JSON.parse(td.dataset.json);
|
|
1492
|
+
document.getElementById('jsonModalTitle').textContent='Inspect Object Value';
|
|
1493
|
+
document.getElementById('jsonModalPre').textContent=JSON.stringify(val, null, 2);
|
|
1494
|
+
document.getElementById('jsonModal').classList.add('on');
|
|
1495
|
+
} catch(e){}
|
|
1496
|
+
};
|
|
1497
|
+
});
|
|
1498
|
+
|
|
1499
|
+
g.querySelectorAll('td.cell-id').forEach(td=>{
|
|
1500
|
+
td.onclick=()=>{
|
|
1501
|
+
const t=td.getAttribute('title')||td.textContent;
|
|
1502
|
+
navigator.clipboard.writeText(t).then(()=>toast('Copied ID to clipboard')).catch(()=>{});
|
|
1503
|
+
};
|
|
1504
|
+
});
|
|
1505
|
+
}
|
|
1506
|
+
|
|
1507
|
+
function filterAndSortRows(){
|
|
1508
|
+
let rows=[...currentRows];
|
|
1509
|
+
const q=document.getElementById('rowSearch').value.toLowerCase().trim();
|
|
1510
|
+
if(q){
|
|
1511
|
+
rows=rows.filter(r=>Object.values(r).some(v=>v!==null&&v!==undefined&&String(typeof v==='object'?JSON.stringify(v):v).toLowerCase().includes(q)));
|
|
1512
|
+
}
|
|
1513
|
+
if(sortCol){
|
|
1514
|
+
rows.sort((a,b)=>{
|
|
1515
|
+
let va=a[sortCol], vb=b[sortCol];
|
|
1516
|
+
if(va===vb) return 0;
|
|
1517
|
+
if(va===null||va===undefined) return 1;
|
|
1518
|
+
if(vb===null||vb===undefined) return -1;
|
|
1519
|
+
if(typeof va==='string') return sortAsc?va.localeCompare(String(vb)):String(vb).localeCompare(va);
|
|
1520
|
+
return sortAsc?(va>vb?1:-1):(va<vb?1:-1);
|
|
1521
|
+
});
|
|
1522
|
+
}
|
|
1523
|
+
renderGrid(rows);
|
|
1524
|
+
}
|
|
1525
|
+
|
|
1526
|
+
document.getElementById('rowSearch').oninput=(e)=>{
|
|
1527
|
+
document.getElementById('rowSearchClear').hidden=!e.target.value;
|
|
1528
|
+
filterAndSortRows();
|
|
1529
|
+
};
|
|
1530
|
+
document.getElementById('rowSearchClear').onclick=()=>{
|
|
1531
|
+
document.getElementById('rowSearch').value='';
|
|
1532
|
+
document.getElementById('rowSearchClear').hidden=true;
|
|
1533
|
+
filterAndSortRows();
|
|
1534
|
+
};
|
|
1535
|
+
|
|
1536
|
+
async function loadRows(){
|
|
1537
|
+
const d=await api('/api/collections/'+encodeURIComponent(cur)+'?skip='+skip+'&limit='+LIMIT);
|
|
1538
|
+
document.getElementById('title').textContent=cur;
|
|
1539
|
+
document.getElementById('meta').textContent=d.total?(skip+1)+'\u2013'+Math.min(skip+LIMIT,d.total)+' of '+d.total:'empty';
|
|
1540
|
+
document.getElementById('prev').disabled=skip===0;
|
|
1541
|
+
document.getElementById('next').disabled=skip+LIMIT>=d.total;
|
|
1542
|
+
|
|
1543
|
+
const canWrite=writable.has(cur);
|
|
1544
|
+
document.getElementById('ins').hidden=!canWrite;
|
|
1545
|
+
document.getElementById('rowSearchWrap').hidden=false;
|
|
1546
|
+
|
|
1547
|
+
const sbTbl=document.getElementById('sbTable');
|
|
1548
|
+
if(sbTbl) sbTbl.textContent=cur;
|
|
1549
|
+
const sbCnt=document.getElementById('sbCount');
|
|
1550
|
+
if(sbCnt) sbCnt.textContent=d.total?(d.total+' '+(d.total===1?'record':'records')):'0 records';
|
|
1551
|
+
const sbMd=document.getElementById('sbMode');
|
|
1552
|
+
if(sbMd) sbMd.textContent=canWrite?'read-write':'read-only';
|
|
1553
|
+
|
|
1554
|
+
currentRows=d.rows;
|
|
1555
|
+
activeColumns=[...new Set(d.rows.flatMap(r=>Object.keys(r)))];
|
|
1556
|
+
filterAndSortRows();
|
|
1557
|
+
}
|
|
1558
|
+
|
|
1559
|
+
async function loadStructure(){
|
|
1560
|
+
const d=await api('/api/collections/'+encodeURIComponent(cur)+'/structure');
|
|
1561
|
+
document.getElementById('title').textContent=cur;
|
|
1562
|
+
document.getElementById('meta').textContent=d.columns.length+' columns \xB7 '+d.indexes.length+' indexes';
|
|
1563
|
+
document.getElementById('prev').disabled=true;
|
|
1564
|
+
document.getElementById('next').disabled=true;
|
|
1565
|
+
document.getElementById('ins').hidden=true;
|
|
1566
|
+
document.getElementById('rowSearch').value='';
|
|
1567
|
+
document.getElementById('rowSearchWrap').hidden=true;
|
|
1568
|
+
|
|
1569
|
+
const sbTbl=document.getElementById('sbTable');
|
|
1570
|
+
if(sbTbl) sbTbl.textContent=cur+' (schema)';
|
|
1571
|
+
const sbCnt=document.getElementById('sbCount');
|
|
1572
|
+
if(sbCnt) sbCnt.textContent=d.columns.length+' cols \xB7 '+d.indexes.length+' idx';
|
|
1573
|
+
|
|
1574
|
+
let h='<div class="structure-wrap">'+
|
|
1575
|
+
'<div class="window-card">'+
|
|
1576
|
+
'<div class="code-bar">'+
|
|
1577
|
+
'<span class="dot r"></span><span class="dot y"></span><span class="dot g"></span>'+
|
|
1578
|
+
'<span class="code-bar-label">COLUMNS ('+d.columns.length+')</span>'+
|
|
1579
|
+
'</div>'+
|
|
1580
|
+
'<table class="data-table" style="width:100%"><thead><tr><th>Column Name</th><th>Data Type</th><th>Nullable</th></tr></thead><tbody>';
|
|
1581
|
+
for(const c of d.columns){
|
|
1582
|
+
h+='<tr><td style="font-weight:600; color:var(--text)">'+esc(c.name)+'</td>'+
|
|
1583
|
+
'<td><span class="type-tag">'+esc(c.type)+'</span></td>'+
|
|
1584
|
+
'<td><span class="null-tag '+(c.nullable?'nullable':'not-null')+'">'+(c.nullable===undefined?'\u2014':(c.nullable?'NULL':'NOT NULL'))+'</span></td></tr>';
|
|
1585
|
+
}
|
|
1586
|
+
h+='</tbody></table></div>'+
|
|
1587
|
+
'<div class="window-card">'+
|
|
1588
|
+
'<div class="code-bar">'+
|
|
1589
|
+
'<span class="dot r"></span><span class="dot y"></span><span class="dot g"></span>'+
|
|
1590
|
+
'<span class="code-bar-label">INDEXES ('+d.indexes.length+')</span>'+
|
|
1591
|
+
'</div>'+
|
|
1592
|
+
'<table class="data-table" style="width:100%"><thead><tr><th>Index Name</th><th>Definition</th></tr></thead><tbody>';
|
|
1593
|
+
for(const idx of d.indexes){
|
|
1594
|
+
h+='<tr><td style="font-weight:600; color:var(--text)">'+esc(idx.name)+'</td>'+
|
|
1595
|
+
'<td style="color:var(--text-dim); font-family:var(--font-mono)">'+esc(idx.definition)+'</td></tr>';
|
|
1596
|
+
}
|
|
1597
|
+
h+='</tbody></table></div></div>';
|
|
1598
|
+
document.getElementById('grid').innerHTML=h;
|
|
1599
|
+
}
|
|
1600
|
+
|
|
1601
|
+
function show(){
|
|
1602
|
+
document.getElementById('btnModeRows').classList.toggle('active', mode==='rows');
|
|
1603
|
+
document.getElementById('btnModeStructure').classList.toggle('active', mode==='structure');
|
|
1604
|
+
return mode==='rows'?loadRows():loadStructure();
|
|
1605
|
+
}
|
|
1606
|
+
|
|
1607
|
+
document.getElementById('btnModeRows').onclick=()=>{
|
|
1608
|
+
if(mode==='rows') return;
|
|
1609
|
+
mode='rows';
|
|
1610
|
+
show();
|
|
1611
|
+
};
|
|
1612
|
+
document.getElementById('btnModeStructure').onclick=()=>{
|
|
1613
|
+
if(mode==='structure') return;
|
|
1614
|
+
mode='structure';
|
|
1615
|
+
show();
|
|
1616
|
+
};
|
|
1617
|
+
document.getElementById('btnRefresh').onclick=()=>show();
|
|
1618
|
+
document.getElementById('prev').onclick=()=>{skip=Math.max(0,skip-LIMIT);loadRows();};
|
|
1619
|
+
document.getElementById('next').onclick=()=>{skip+=LIMIT;loadRows();};
|
|
1620
|
+
document.getElementById('ins').onclick=()=>openEditor(null);
|
|
1621
|
+
|
|
1622
|
+
function updateEditorForm(vals){
|
|
1623
|
+
const f=document.getElementById('edFormFields');
|
|
1624
|
+
f.innerHTML='';
|
|
1625
|
+
const keys=[...new Set([...Object.keys(vals), ...activeColumns.filter(c=>!SKIP.has(c))])];
|
|
1626
|
+
if(!keys.length){
|
|
1627
|
+
f.innerHTML='<div style="grid-column: span 2; color:var(--text-muted); padding:10px 0;">No editable fields</div>';
|
|
1628
|
+
return;
|
|
1629
|
+
}
|
|
1630
|
+
for(const k of keys){
|
|
1631
|
+
const l=document.createElement('div');
|
|
1632
|
+
l.className='form-label';
|
|
1633
|
+
l.textContent=k;
|
|
1634
|
+
const v=vals[k];
|
|
1635
|
+
const inp=document.createElement('input');
|
|
1636
|
+
inp.className='form-input';
|
|
1637
|
+
inp.dataset.key=k;
|
|
1638
|
+
if(typeof v==='number') {
|
|
1639
|
+
inp.type='number';
|
|
1640
|
+
inp.value=v;
|
|
1641
|
+
} else if(typeof v==='boolean') {
|
|
1642
|
+
inp.type='text';
|
|
1643
|
+
inp.value=String(v);
|
|
1644
|
+
inp.placeholder='true / false';
|
|
1645
|
+
} else if(typeof v==='object'&&v!==null) {
|
|
1646
|
+
inp.type='text';
|
|
1647
|
+
inp.value=JSON.stringify(v);
|
|
1648
|
+
} else {
|
|
1649
|
+
inp.type='text';
|
|
1650
|
+
inp.value=v===undefined||v===null?'':String(v);
|
|
1651
|
+
}
|
|
1652
|
+
inp.oninput=syncFormToJson;
|
|
1653
|
+
f.appendChild(l);
|
|
1654
|
+
f.appendChild(inp);
|
|
1655
|
+
}
|
|
1656
|
+
}
|
|
1657
|
+
|
|
1658
|
+
function syncFormToJson(){
|
|
1659
|
+
const f=document.getElementById('edFormFields');
|
|
1660
|
+
const res={};
|
|
1661
|
+
f.querySelectorAll('.form-input').forEach(inp=>{
|
|
1662
|
+
const k=inp.dataset.key;
|
|
1663
|
+
const raw=inp.value.trim();
|
|
1664
|
+
if(raw==='') return;
|
|
1665
|
+
if(raw==='true') res[k]=true;
|
|
1666
|
+
else if(raw==='false') res[k]=false;
|
|
1667
|
+
else if(raw==='null') res[k]=null;
|
|
1668
|
+
else if(!isNaN(Number(raw))&&inp.type==='number') res[k]=Number(raw);
|
|
1669
|
+
else if((raw.startsWith('{')&&raw.endsWith('}'))||(raw.startsWith('[')&&raw.endsWith(']'))){
|
|
1670
|
+
try { res[k]=JSON.parse(raw); } catch { res[k]=raw; }
|
|
1671
|
+
} else {
|
|
1672
|
+
res[k]=raw;
|
|
1673
|
+
}
|
|
1674
|
+
});
|
|
1675
|
+
document.getElementById('edText').value=JSON.stringify(res, null, 2);
|
|
1676
|
+
}
|
|
1677
|
+
|
|
1678
|
+
function syncJsonToForm(){
|
|
1679
|
+
try {
|
|
1680
|
+
const v=JSON.parse(document.getElementById('edText').value);
|
|
1681
|
+
updateEditorForm(v);
|
|
1682
|
+
document.getElementById('edErr').classList.remove('on');
|
|
1683
|
+
} catch(e){
|
|
1684
|
+
document.getElementById('edErr').textContent='Not valid JSON: '+e.message;
|
|
1685
|
+
document.getElementById('edErr').classList.add('on');
|
|
1686
|
+
}
|
|
1687
|
+
}
|
|
1688
|
+
|
|
1689
|
+
function openEditor(row){
|
|
1690
|
+
editing=row;
|
|
1691
|
+
const v={};
|
|
1692
|
+
if(row){
|
|
1693
|
+
for(const [k,x] of Object.entries(row)){
|
|
1694
|
+
if(!SKIP.has(k)) v[k]=x;
|
|
1695
|
+
}
|
|
1696
|
+
}
|
|
1697
|
+
document.getElementById('edTitle').textContent=row?'Edit '+cur+' #'+(row.id??row._id):'New record in '+cur;
|
|
1698
|
+
document.getElementById('edText').value=JSON.stringify(v, null, 2);
|
|
1699
|
+
updateEditorForm(v);
|
|
1700
|
+
document.getElementById('edErr').classList.remove('on');
|
|
1701
|
+
document.getElementById('edDel').hidden=!row;
|
|
1702
|
+
setEditorTab('form');
|
|
1703
|
+
document.getElementById('ed').classList.add('on');
|
|
1704
|
+
}
|
|
1705
|
+
|
|
1706
|
+
function closeEditor(){
|
|
1707
|
+
document.getElementById('ed').classList.remove('on');
|
|
1708
|
+
editing=null;
|
|
1709
|
+
}
|
|
1710
|
+
|
|
1711
|
+
function setEditorTab(tab){
|
|
1712
|
+
document.getElementById('edTabForm').classList.toggle('active', tab==='form');
|
|
1713
|
+
document.getElementById('edTabJson').classList.toggle('active', tab==='json');
|
|
1714
|
+
document.getElementById('edFormPanel').style.display=tab==='form'?'block':'none';
|
|
1715
|
+
document.getElementById('edJsonPanel').style.display=tab==='json'?'block':'none';
|
|
1716
|
+
}
|
|
1717
|
+
|
|
1718
|
+
document.getElementById('edTabForm').onclick=()=>{
|
|
1719
|
+
syncJsonToForm();
|
|
1720
|
+
setEditorTab('form');
|
|
1721
|
+
};
|
|
1722
|
+
document.getElementById('edTabJson').onclick=()=>{
|
|
1723
|
+
syncFormToJson();
|
|
1724
|
+
setEditorTab('json');
|
|
1725
|
+
};
|
|
1726
|
+
|
|
1727
|
+
document.getElementById('edClose').onclick=closeEditor;
|
|
1728
|
+
document.getElementById('edCancel').onclick=closeEditor;
|
|
1729
|
+
|
|
1730
|
+
document.getElementById('edSave').onclick=async()=>{
|
|
1731
|
+
const err=document.getElementById('edErr');
|
|
1732
|
+
let v;
|
|
1733
|
+
try {
|
|
1734
|
+
v=JSON.parse(document.getElementById('edText').value);
|
|
1735
|
+
} catch(e){
|
|
1736
|
+
err.textContent='Not valid JSON: '+e.message;
|
|
1737
|
+
err.classList.add('on');
|
|
1738
|
+
return;
|
|
1739
|
+
}
|
|
1740
|
+
|
|
1741
|
+
const base='/api/collections/'+encodeURIComponent(cur);
|
|
1742
|
+
try {
|
|
1743
|
+
if(editing){
|
|
1744
|
+
const ch={};
|
|
1745
|
+
for(const [k,x] of Object.entries(v)){
|
|
1746
|
+
if(JSON.stringify(x)!==JSON.stringify(editing[k])) ch[k]=x;
|
|
1747
|
+
}
|
|
1748
|
+
if(Object.keys(ch).length){
|
|
1749
|
+
await send('PATCH', base+'/'+encodeURIComponent(editing.id??editing._id), ch);
|
|
1750
|
+
toast('Record updated');
|
|
1751
|
+
}
|
|
1752
|
+
} else {
|
|
1753
|
+
await send('POST', base, v);
|
|
1754
|
+
toast('Record created');
|
|
1755
|
+
}
|
|
1756
|
+
closeEditor();
|
|
1757
|
+
await loadList();
|
|
1758
|
+
await loadRows();
|
|
1759
|
+
} catch(e){
|
|
1760
|
+
err.textContent=e.message+(e.issues?'\\n'+JSON.stringify(e.issues,null,2):'');
|
|
1761
|
+
err.classList.add('on');
|
|
1762
|
+
}
|
|
1763
|
+
};
|
|
1764
|
+
|
|
1765
|
+
document.getElementById('edDel').onclick=async()=>{
|
|
1766
|
+
if(!confirm('Delete this record?')) return;
|
|
1767
|
+
try {
|
|
1768
|
+
await send('DELETE', '/api/collections/'+encodeURIComponent(cur)+'/'+encodeURIComponent(editing.id??editing._id));
|
|
1769
|
+
toast('Record deleted');
|
|
1770
|
+
closeEditor();
|
|
1771
|
+
await loadList();
|
|
1772
|
+
await loadRows();
|
|
1773
|
+
} catch(e){
|
|
1774
|
+
document.getElementById('edErr').textContent=e.message;
|
|
1775
|
+
document.getElementById('edErr').classList.add('on');
|
|
1776
|
+
}
|
|
1777
|
+
};
|
|
1778
|
+
|
|
1779
|
+
document.getElementById('jsonModalClose').onclick=()=>document.getElementById('jsonModal').classList.remove('on');
|
|
1780
|
+
document.getElementById('jsonModalCopy').onclick=()=>{
|
|
1781
|
+
navigator.clipboard.writeText(document.getElementById('jsonModalPre').textContent)
|
|
1782
|
+
.then(()=>toast('Copied JSON to clipboard')).catch(()=>{});
|
|
1783
|
+
};
|
|
1784
|
+
|
|
1785
|
+
window.addEventListener('keydown', e=>{
|
|
1786
|
+
if(e.key==='Escape'){
|
|
1787
|
+
closeEditor();
|
|
1788
|
+
document.getElementById('jsonModal').classList.remove('on');
|
|
1789
|
+
}
|
|
1790
|
+
if((e.ctrlKey||e.metaKey)&&e.key==='Enter'){
|
|
1791
|
+
if(document.getElementById('ed').classList.contains('on')){
|
|
1792
|
+
document.getElementById('edSave').click();
|
|
1793
|
+
}
|
|
1794
|
+
}
|
|
1795
|
+
});
|
|
1796
|
+
|
|
1797
|
+
loadList().catch(e=>{
|
|
1798
|
+
document.getElementById('grid').innerHTML='<div class="empty-state"><h3>Error loading database</h3><p>'+esc(e.message)+'</p></div>';
|
|
1799
|
+
});
|
|
1800
|
+
</script>
|
|
1801
|
+
</body>
|
|
1802
|
+
</html>`;
|
|
1803
|
+
|
|
1804
|
+
// src/db/studio.ts
|
|
179
1805
|
function mongoSource(conn) {
|
|
180
1806
|
const db = conn.db;
|
|
181
1807
|
return {
|
|
182
1808
|
async collections() {
|
|
183
1809
|
const cols = (await db.listCollections({}, { nameOnly: true }).toArray()).map((c) => c.name).filter((n) => !n.startsWith("system.")).sort();
|
|
184
|
-
|
|
185
|
-
cols.map(async (name) =>
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
1810
|
+
const counted = await Promise.all(
|
|
1811
|
+
cols.map(async (name) => {
|
|
1812
|
+
try {
|
|
1813
|
+
return { name, count: await db.collection(name).estimatedDocumentCount() };
|
|
1814
|
+
} catch (e) {
|
|
1815
|
+
return void 0;
|
|
1816
|
+
}
|
|
1817
|
+
})
|
|
189
1818
|
);
|
|
1819
|
+
return counted.filter((c) => c !== void 0);
|
|
190
1820
|
},
|
|
191
1821
|
async rows(name, skip, limit) {
|
|
192
1822
|
const col = db.collection(name);
|
|
@@ -225,12 +1855,19 @@ function pgSource(pool) {
|
|
|
225
1855
|
const q = (ident) => `"${ident.replace(/"/g, '""')}"`;
|
|
226
1856
|
return {
|
|
227
1857
|
async collections() {
|
|
228
|
-
|
|
229
|
-
(await tables()).map(async (name) =>
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
1858
|
+
const counted = await Promise.all(
|
|
1859
|
+
(await tables()).map(async (name) => {
|
|
1860
|
+
try {
|
|
1861
|
+
const { rows } = await pool.query(
|
|
1862
|
+
`SELECT count(*)::int AS n FROM ${q(name)}`
|
|
1863
|
+
);
|
|
1864
|
+
return { name, count: rows[0].n };
|
|
1865
|
+
} catch (e2) {
|
|
1866
|
+
return void 0;
|
|
1867
|
+
}
|
|
1868
|
+
})
|
|
233
1869
|
);
|
|
1870
|
+
return counted.filter((c) => c !== void 0);
|
|
234
1871
|
},
|
|
235
1872
|
async rows(name, skip, limit) {
|
|
236
1873
|
if (!(await tables()).includes(name))
|
|
@@ -261,96 +1898,127 @@ function pgSource(pool) {
|
|
|
261
1898
|
}
|
|
262
1899
|
};
|
|
263
1900
|
}
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
.
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
.
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
const esc=s=>String(s).replace(/[&<>"]/g,c=>({'&':'&','<':'<','>':'>','"':'"'}[c]));
|
|
291
|
-
async function api(p){const r=await fetch(p);if(!r.ok)throw new Error((await r.json()).error);return r.json()}
|
|
292
|
-
async function loadList(){const d=await api('/api/collections');document.getElementById('engine').textContent='\xB7 '+d.engine;
|
|
293
|
-
const el=document.getElementById('list');el.innerHTML='';
|
|
294
|
-
for(const c of d.collections){const b=document.createElement('button');b.innerHTML=esc(c.name)+'<small>'+c.count+'</small>';
|
|
295
|
-
b.onclick=()=>{cur=c.name;skip=0;[...el.children].forEach(x=>x.classList.remove('on'));b.classList.add('on');document.getElementById('view').disabled=false;show()};el.appendChild(b)}
|
|
296
|
-
if(!d.collections.length)el.innerHTML='<div class="empty">No tables yet.</div>'}
|
|
297
|
-
async function loadRows(){const d=await api('/api/collections/'+encodeURIComponent(cur)+'?skip='+skip+'&limit='+LIMIT);
|
|
298
|
-
document.getElementById('title').textContent=cur;
|
|
299
|
-
document.getElementById('meta').textContent=d.total?(skip+1)+'\u2013'+Math.min(skip+LIMIT,d.total)+' of '+d.total:'empty';
|
|
300
|
-
document.getElementById('prev').disabled=skip===0;document.getElementById('next').disabled=skip+LIMIT>=d.total;
|
|
301
|
-
const cols=[...new Set(d.rows.flatMap(r=>Object.keys(r)))];const g=document.getElementById('grid');
|
|
302
|
-
if(!d.rows.length){g.innerHTML='<div class="empty">No rows.</div>';return}
|
|
303
|
-
let h='<table><thead><tr>'+cols.map(c=>'<th>'+esc(c)+'</th>').join('')+'</tr></thead><tbody>';
|
|
304
|
-
for(const r of d.rows){h+='<tr>'+cols.map(c=>{const v=r[c];if(v===null||v===undefined)return '<td class="null">null</td>';
|
|
305
|
-
if(typeof v==='object'){const j=JSON.stringify(v);return '<td class="obj" title="click to expand" data-j="'+esc(j)+'">'+esc(j)+'</td>'}
|
|
306
|
-
return '<td title="'+esc(v)+'">'+esc(v)+'</td>'}).join('')+'</tr>'}
|
|
307
|
-
g.innerHTML=h+'</tbody></table>';
|
|
308
|
-
g.querySelectorAll('td.obj').forEach(td=>td.onclick=()=>{td.innerHTML='<pre>'+esc(JSON.stringify(JSON.parse(td.dataset.j),null,2))+'</pre>';td.style.whiteSpace='normal';td.onclick=null})}
|
|
309
|
-
function show(){document.getElementById('view').textContent=mode==='rows'?'Structure':'Rows';return mode==='rows'?loadRows():loadStructure()}
|
|
310
|
-
async function loadStructure(){const d=await api('/api/collections/'+encodeURIComponent(cur)+'/structure');
|
|
311
|
-
document.getElementById('title').textContent=cur;document.getElementById('meta').textContent=d.columns.length+' columns \xB7 '+d.indexes.length+' indexes';
|
|
312
|
-
document.getElementById('prev').disabled=true;document.getElementById('next').disabled=true;
|
|
313
|
-
const row=(cells)=>'<tr>'+cells.map(c=>'<td>'+esc(c)+'</td>').join('')+'</tr>';
|
|
314
|
-
document.getElementById('grid').innerHTML='<table><thead><tr><th>column</th><th>type</th><th>nullable</th></tr></thead><tbody>'+
|
|
315
|
-
d.columns.map(c=>row([c.name,c.type,c.nullable===undefined?'':String(c.nullable)])).join('')+'</tbody></table>'+
|
|
316
|
-
'<table style="margin-top:18px"><thead><tr><th>index</th><th>definition</th></tr></thead><tbody>'+d.indexes.map(i=>row([i.name,i.definition])).join('')+'</tbody></table>'}
|
|
317
|
-
document.getElementById('view').onclick=()=>{mode=mode==='rows'?'structure':'rows';skip=0;show()};
|
|
318
|
-
document.getElementById('prev').onclick=()=>{skip=Math.max(0,skip-LIMIT);loadRows()};
|
|
319
|
-
document.getElementById('next').onclick=()=>{skip+=LIMIT;loadRows()};
|
|
320
|
-
loadList().catch(e=>document.getElementById('grid').innerHTML='<div class="empty">'+esc(e.message)+'</div>');
|
|
321
|
-
</script></body></html>`;
|
|
322
|
-
function startStudio(engine, client, port) {
|
|
1901
|
+
function readJson(req) {
|
|
1902
|
+
return new Promise((resolve, reject) => {
|
|
1903
|
+
let size = 0;
|
|
1904
|
+
const chunks = [];
|
|
1905
|
+
req.on("data", (c) => {
|
|
1906
|
+
size += c.length;
|
|
1907
|
+
if (size > 1048576) {
|
|
1908
|
+
reject(Object.assign(new Error("Body too large"), { status: 413 }));
|
|
1909
|
+
req.destroy();
|
|
1910
|
+
} else chunks.push(c);
|
|
1911
|
+
});
|
|
1912
|
+
req.on("end", () => {
|
|
1913
|
+
try {
|
|
1914
|
+
const v = JSON.parse(Buffer.concat(chunks).toString("utf8") || "{}");
|
|
1915
|
+
if (!v || typeof v !== "object" || Array.isArray(v))
|
|
1916
|
+
throw new Error("Expected a JSON object");
|
|
1917
|
+
resolve(v);
|
|
1918
|
+
} catch (err) {
|
|
1919
|
+
reject(Object.assign(new Error(err.message), { status: 400 }));
|
|
1920
|
+
}
|
|
1921
|
+
});
|
|
1922
|
+
req.on("error", reject);
|
|
1923
|
+
});
|
|
1924
|
+
}
|
|
1925
|
+
var SERVER_FIELDS = ["_id", "id", "__v", "createdAt", "updatedAt"];
|
|
1926
|
+
function startStudio(engine, client, port, options = {}) {
|
|
323
1927
|
const source = engine === "postgresql" ? pgSource(client) : mongoSource(client);
|
|
324
1928
|
const json = (res, status, body) => {
|
|
325
1929
|
res.writeHead(status, { "Content-Type": "application/json" });
|
|
326
|
-
res.end(JSON.stringify(body));
|
|
1930
|
+
res.end(JSON.stringify(body, (_k, v) => typeof v === "bigint" ? v.toString() : v));
|
|
1931
|
+
};
|
|
1932
|
+
const token = _crypto2.default.randomBytes(32).toString("hex");
|
|
1933
|
+
const page = STUDIO_HTML.replace("__EFC_TOKEN__", JSON.stringify(options.write ? token : ""));
|
|
1934
|
+
let writers;
|
|
1935
|
+
const writerFor = async (name) => {
|
|
1936
|
+
if (!options.write) return void 0;
|
|
1937
|
+
writers ??= (async () => {
|
|
1938
|
+
const map = /* @__PURE__ */ new Map();
|
|
1939
|
+
for (const m of _nullishCoalesce(options.models, () => ( []))) {
|
|
1940
|
+
if (!m.studio) continue;
|
|
1941
|
+
try {
|
|
1942
|
+
map.set(await m.studio.storage(), m.studio);
|
|
1943
|
+
} catch (e3) {
|
|
1944
|
+
}
|
|
1945
|
+
}
|
|
1946
|
+
return map;
|
|
1947
|
+
})();
|
|
1948
|
+
return (await writers).get(name);
|
|
327
1949
|
};
|
|
328
1950
|
const server = _http2.default.createServer((req, res) => {
|
|
329
1951
|
void (async () => {
|
|
330
1952
|
const url = new URL(_nullishCoalesce(req.url, () => ( "/")), "http://localhost");
|
|
331
|
-
const
|
|
1953
|
+
const rawHost = _nullishCoalesce(req.headers.host, () => ( ""));
|
|
1954
|
+
const host = rawHost.replace(/:\d+$/, "").replace(/^\[|\]$/g, "");
|
|
332
1955
|
if (!["localhost", "127.0.0.1", "::1"].includes(host)) {
|
|
333
1956
|
return json(res, 403, { error: "Studio only answers on localhost" });
|
|
334
1957
|
}
|
|
335
|
-
if (req.method !== "GET")
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
1958
|
+
if (req.method !== "GET") {
|
|
1959
|
+
if (!options.write)
|
|
1960
|
+
return json(res, 405, { error: "Studio is read-only (start it with --write)" });
|
|
1961
|
+
const sent = String(_nullishCoalesce(req.headers["x-efc-studio-token"], () => ( "")));
|
|
1962
|
+
const ok = sent.length === token.length && _crypto2.default.timingSafeEqual(Buffer.from(sent), Buffer.from(token)) && req.headers.origin === `http://${rawHost}` && String(_nullishCoalesce(req.headers["content-type"], () => ( ""))).startsWith("application/json");
|
|
1963
|
+
if (!ok) return json(res, 403, { error: "Missing or invalid studio token" });
|
|
339
1964
|
}
|
|
340
|
-
if (url.pathname === "/
|
|
341
|
-
|
|
1965
|
+
if (req.method === "GET" && url.pathname === "/") {
|
|
1966
|
+
res.writeHead(200, {
|
|
1967
|
+
"Content-Type": "text/html; charset=utf-8",
|
|
1968
|
+
"Cache-Control": "no-store",
|
|
1969
|
+
"X-Frame-Options": "DENY"
|
|
1970
|
+
});
|
|
1971
|
+
return res.end(page);
|
|
1972
|
+
}
|
|
1973
|
+
if (req.method === "GET" && url.pathname === "/api/collections") {
|
|
1974
|
+
const collections = await source.collections();
|
|
1975
|
+
return json(res, 200, {
|
|
1976
|
+
engine,
|
|
1977
|
+
write: !!options.write,
|
|
1978
|
+
collections: await Promise.all(
|
|
1979
|
+
collections.map(async (c) => ({ ...c, writable: !!await writerFor(c.name) }))
|
|
1980
|
+
)
|
|
1981
|
+
});
|
|
342
1982
|
}
|
|
343
1983
|
const st = /^\/api\/collections\/([^/]+)\/structure$/.exec(url.pathname);
|
|
344
|
-
if (
|
|
1984
|
+
if (req.method === "GET" && st)
|
|
1985
|
+
return json(res, 200, await source.structure(decodeURIComponent(st[1])));
|
|
345
1986
|
const m = /^\/api\/collections\/([^/]+)$/.exec(url.pathname);
|
|
346
|
-
if (m) {
|
|
1987
|
+
if (req.method === "GET" && m) {
|
|
347
1988
|
const skip = Math.max(0, Number(url.searchParams.get("skip")) || 0);
|
|
348
1989
|
const limit = Math.min(500, Math.max(1, Number(url.searchParams.get("limit")) || 50));
|
|
349
1990
|
return json(res, 200, await source.rows(decodeURIComponent(m[1]), skip, limit));
|
|
350
1991
|
}
|
|
1992
|
+
const w = /^\/api\/collections\/([^/]+)(?:\/([^/]+))?$/.exec(url.pathname);
|
|
1993
|
+
if (w && req.method !== "GET") {
|
|
1994
|
+
const name = decodeURIComponent(w[1]);
|
|
1995
|
+
const id = w[2] !== void 0 ? decodeURIComponent(w[2]) : void 0;
|
|
1996
|
+
const writer = await writerFor(name);
|
|
1997
|
+
if (!writer) {
|
|
1998
|
+
return json(res, 409, {
|
|
1999
|
+
error: `No model stores in "${name}" \u2014 studio writes go through your models (src/model)`
|
|
2000
|
+
});
|
|
2001
|
+
}
|
|
2002
|
+
const body = req.method === "DELETE" ? {} : await readJson(req);
|
|
2003
|
+
for (const k of SERVER_FIELDS) delete body[k];
|
|
2004
|
+
if (req.method === "POST" && id === void 0)
|
|
2005
|
+
return json(res, 201, { record: await writer.create(body) });
|
|
2006
|
+
if (req.method === "PATCH" && id !== void 0) {
|
|
2007
|
+
const record = await writer.update(id, body);
|
|
2008
|
+
return record ? json(res, 200, { record }) : json(res, 404, { error: "Not found" });
|
|
2009
|
+
}
|
|
2010
|
+
if (req.method === "DELETE" && id !== void 0) {
|
|
2011
|
+
const record = await writer.delete(id);
|
|
2012
|
+
return record ? json(res, 200, { record }) : json(res, 404, { error: "Not found" });
|
|
2013
|
+
}
|
|
2014
|
+
return json(res, 405, { error: "Method not allowed" });
|
|
2015
|
+
}
|
|
351
2016
|
json(res, 404, { error: "Not found" });
|
|
352
2017
|
})().catch(
|
|
353
|
-
(err) => json(res, _nullishCoalesce(err.status, () => (
|
|
2018
|
+
(err) => json(res, _nullishCoalesce(_nullishCoalesce(err.status, () => ( err.statusCode)), () => ( 500)), {
|
|
2019
|
+
error: err.message,
|
|
2020
|
+
...err.issues !== void 0 && { issues: err.issues }
|
|
2021
|
+
})
|
|
354
2022
|
);
|
|
355
2023
|
});
|
|
356
2024
|
return new Promise((resolve, reject) => {
|
|
@@ -520,7 +2188,7 @@ function scalarType(type) {
|
|
|
520
2188
|
if (type === "jsonb" || type === "json") return { def: { type: "json" } };
|
|
521
2189
|
return { def: { type: "json" }, note: `${type} has no EFC type \u2014 mapped to json` };
|
|
522
2190
|
}
|
|
523
|
-
async function pullPostgres(pool) {
|
|
2191
|
+
async function pullPostgres(pool, names = /* @__PURE__ */ new Map()) {
|
|
524
2192
|
const q = async (sql) => (await pool.query(sql)).rows;
|
|
525
2193
|
const tables = (await q(
|
|
526
2194
|
`SELECT c.relname AS name FROM pg_class c JOIN pg_namespace n ON n.oid = c.relnamespace
|
|
@@ -561,8 +2229,8 @@ async function pullPostgres(pool) {
|
|
|
561
2229
|
const fksOf = (t) => fks.filter((f) => f.table === t);
|
|
562
2230
|
const joinTables = /* @__PURE__ */ new Map();
|
|
563
2231
|
for (const t of tables) {
|
|
564
|
-
const
|
|
565
|
-
if (
|
|
2232
|
+
const names2 = colsOf(t).map((c) => c.name).sort().join(",");
|
|
2233
|
+
if (names2 !== "owner_id,position,ref_id") continue;
|
|
566
2234
|
const owner = _optionalChain([fksOf, 'call', _8 => _8(t), 'access', _9 => _9.find, 'call', _10 => _10((f) => f.columns[0] === "owner_id"), 'optionalAccess', _11 => _11.target]);
|
|
567
2235
|
const target = _optionalChain([fksOf, 'call', _12 => _12(t), 'access', _13 => _13.find, 'call', _14 => _14((f) => f.columns[0] === "ref_id"), 'optionalAccess', _15 => _15.target]);
|
|
568
2236
|
if (owner && target && t.startsWith(`${owner}_`))
|
|
@@ -583,7 +2251,7 @@ async function pullPostgres(pool) {
|
|
|
583
2251
|
skipped.push(t);
|
|
584
2252
|
continue;
|
|
585
2253
|
}
|
|
586
|
-
models.set(t, { table: t, name:
|
|
2254
|
+
models.set(t, { table: t, name: _nullishCoalesce(names.get(t), () => ( _chunkM53GODCXcjs.pascal.call(void 0, _chunkM53GODCXcjs.singular.call(void 0, t)))), idKind });
|
|
587
2255
|
}
|
|
588
2256
|
const modelName = (t) => _optionalChain([models, 'access', _16 => _16.get, 'call', _17 => _17(t), 'optionalAccess', _18 => _18.name]);
|
|
589
2257
|
const out = [];
|
|
@@ -593,14 +2261,14 @@ async function pullPostgres(pool) {
|
|
|
593
2261
|
const cols = colsOf(table);
|
|
594
2262
|
const notes = [];
|
|
595
2263
|
const underscored = cols.filter((c) => c.name.includes("_"));
|
|
596
|
-
const snake = underscored.length > 0 && underscored.every((c) =>
|
|
597
|
-
const fieldOf = (column) => snake ?
|
|
2264
|
+
const snake = underscored.length > 0 && underscored.every((c) => _chunkIUZ6A7PBcjs.snakeCase.call(void 0, _chunkM53GODCXcjs.camel.call(void 0, c.name)) === c.name);
|
|
2265
|
+
const fieldOf = (column) => snake ? _chunkM53GODCXcjs.camel.call(void 0, column) : column;
|
|
598
2266
|
const options = {};
|
|
599
2267
|
if (snake) options["naming"] = "snake_case";
|
|
600
2268
|
if (idKind !== "uuid") options["id"] = idKind;
|
|
601
|
-
const defaultTable =
|
|
2269
|
+
const defaultTable = _chunkIUZ6A7PBcjs.tableNameFor.call(void 0, snake ? _chunkIUZ6A7PBcjs.snakeCase.call(void 0, name) : name);
|
|
602
2270
|
if (defaultTable !== table) options["collection"] = table;
|
|
603
|
-
const tsColumn = (f) => cols.find((c) => c.name === (snake ?
|
|
2271
|
+
const tsColumn = (f) => cols.find((c) => c.name === (snake ? _chunkIUZ6A7PBcjs.snakeCase.call(void 0, f) : f));
|
|
604
2272
|
const isTs = (c) => _optionalChain([c, 'optionalAccess', _19 => _19.type]) === "timestamp with time zone";
|
|
605
2273
|
const hasCreated = isTs(tsColumn("createdAt"));
|
|
606
2274
|
const hasUpdated = isTs(tsColumn("updatedAt"));
|
|
@@ -624,9 +2292,9 @@ async function pullPostgres(pool) {
|
|
|
624
2292
|
let field = fieldOf(col.name);
|
|
625
2293
|
const fkCol = tableFks.some((f) => f.columns.length === 1 && f.columns[0] === col.name);
|
|
626
2294
|
const stem = _optionalChain([/^(.+?)(?:Id|_id)$/, 'access', _20 => _20.exec, 'call', _21 => _21(col.name), 'optionalAccess', _22 => _22[1]]);
|
|
627
|
-
if (fkCol && stem && !taken.has(
|
|
628
|
-
taken.add(
|
|
629
|
-
field =
|
|
2295
|
+
if (fkCol && stem && !taken.has(_chunkM53GODCXcjs.camel.call(void 0, stem))) {
|
|
2296
|
+
taken.add(_chunkM53GODCXcjs.camel.call(void 0, stem));
|
|
2297
|
+
field = _chunkM53GODCXcjs.camel.call(void 0, stem);
|
|
630
2298
|
}
|
|
631
2299
|
let def;
|
|
632
2300
|
if (col.enumLabels) {
|
|
@@ -657,7 +2325,7 @@ async function pullPostgres(pool) {
|
|
|
657
2325
|
def["default"] = /^'((?:[^']|'')*)'/.exec(d)[1].replace(/''/g, "'");
|
|
658
2326
|
else notes.push(`${field}: database default ${d} not carried over`);
|
|
659
2327
|
}
|
|
660
|
-
if ((snake ?
|
|
2328
|
+
if ((snake ? _chunkIUZ6A7PBcjs.snakeCase.call(void 0, field) : field) !== col.name) def["column"] = col.name;
|
|
661
2329
|
const fk = tableFks.find((f) => f.columns.length === 1 && f.columns[0] === col.name);
|
|
662
2330
|
if (fk) {
|
|
663
2331
|
const target = modelName(fk.target);
|
|
@@ -700,7 +2368,7 @@ async function pullPostgres(pool) {
|
|
|
700
2368
|
const of = target.idKind === "uuid" ? "uuid" : target.idKind === "bigserial" ? "bigint" : "integer";
|
|
701
2369
|
fields.push([fieldOf(j.column), { type: "array", of, ref: target.name }]);
|
|
702
2370
|
}
|
|
703
|
-
const fieldOfColumn = (c) => _nullishCoalesce(_optionalChain([fields, 'access', _31 => _31.find, 'call', _32 => _32(([f, d]) => (_nullishCoalesce(d["column"], () => ( (snake ?
|
|
2371
|
+
const fieldOfColumn = (c) => _nullishCoalesce(_optionalChain([fields, 'access', _31 => _31.find, 'call', _32 => _32(([f, d]) => (_nullishCoalesce(d["column"], () => ( (snake ? _chunkIUZ6A7PBcjs.snakeCase.call(void 0, f) : f)))) === c), 'optionalAccess', _33 => _33[0]]), () => ( fieldOf(c)));
|
|
704
2372
|
const indexDefs = [];
|
|
705
2373
|
for (const idx of tableIndexes) {
|
|
706
2374
|
if (usedIndexes.has(idx.name)) continue;
|
|
@@ -745,8 +2413,8 @@ async function pullPostgres(pool) {
|
|
|
745
2413
|
for (const field of refFields) {
|
|
746
2414
|
const def = fields.find(([f]) => f === field)[1];
|
|
747
2415
|
const many = def["type"] === "array" || !def["unique"];
|
|
748
|
-
let rel = many ?
|
|
749
|
-
if (refFields.length > 1) rel = `${rel}By${
|
|
2416
|
+
let rel = many ? _chunkM53GODCXcjs.plural.call(void 0, _chunkM53GODCXcjs.lcFirst.call(void 0, name)) : _chunkM53GODCXcjs.lcFirst.call(void 0, name);
|
|
2417
|
+
if (refFields.length > 1) rel = `${rel}By${_chunkM53GODCXcjs.pascal.call(void 0, field)}`;
|
|
750
2418
|
const taken2 = _nullishCoalesce(relationNames.get(target), () => ( /* @__PURE__ */ new Set()));
|
|
751
2419
|
while (taken2.has(rel)) rel = `${rel}_`;
|
|
752
2420
|
taken2.add(rel);
|
|
@@ -756,7 +2424,7 @@ async function pullPostgres(pool) {
|
|
|
756
2424
|
relations.set(target, rels);
|
|
757
2425
|
}
|
|
758
2426
|
}
|
|
759
|
-
out.push({ name, fields, options, notes });
|
|
2427
|
+
out.push({ name, fields, options, notes, table });
|
|
760
2428
|
}
|
|
761
2429
|
for (const model of out) {
|
|
762
2430
|
const rels = relations.get(model.name);
|
|
@@ -769,6 +2437,230 @@ async function pullPostgres(pool) {
|
|
|
769
2437
|
return { models: out, skipped };
|
|
770
2438
|
}
|
|
771
2439
|
|
|
2440
|
+
// src/db/pull-mongo.ts
|
|
2441
|
+
var INTERNAL2 = /* @__PURE__ */ new Set(["efc_migrations", "efc_counters"]);
|
|
2442
|
+
var newShape = () => ({ present: 0, kinds: /* @__PURE__ */ new Map() });
|
|
2443
|
+
function bsonKind(v) {
|
|
2444
|
+
if (v === null || v === void 0) return "null";
|
|
2445
|
+
if (typeof v === "string") return "string";
|
|
2446
|
+
if (typeof v === "number") return "number";
|
|
2447
|
+
if (typeof v === "boolean") return "boolean";
|
|
2448
|
+
if (v instanceof Date) return "date";
|
|
2449
|
+
if (Array.isArray(v)) return "array";
|
|
2450
|
+
if (typeof v === "object") {
|
|
2451
|
+
switch (v._bsontype) {
|
|
2452
|
+
case "ObjectId":
|
|
2453
|
+
case "ObjectID":
|
|
2454
|
+
return "objectId";
|
|
2455
|
+
case "Decimal128":
|
|
2456
|
+
return "decimal128";
|
|
2457
|
+
case "Long":
|
|
2458
|
+
return "long";
|
|
2459
|
+
case "Int32":
|
|
2460
|
+
case "Double":
|
|
2461
|
+
return "number";
|
|
2462
|
+
case "Binary":
|
|
2463
|
+
return "binary";
|
|
2464
|
+
case void 0:
|
|
2465
|
+
break;
|
|
2466
|
+
default:
|
|
2467
|
+
return "other";
|
|
2468
|
+
}
|
|
2469
|
+
if (Buffer.isBuffer(v)) return "binary";
|
|
2470
|
+
const o = v;
|
|
2471
|
+
if (o["type"] === "Point" && Array.isArray(o["coordinates"]) && o["coordinates"].length === 2 && o["coordinates"].every((c) => bsonKind(c) === "number")) {
|
|
2472
|
+
return "geoPoint";
|
|
2473
|
+
}
|
|
2474
|
+
return "object";
|
|
2475
|
+
}
|
|
2476
|
+
return "other";
|
|
2477
|
+
}
|
|
2478
|
+
function observe(shape, value) {
|
|
2479
|
+
const kind = bsonKind(value);
|
|
2480
|
+
if (kind === "null") return;
|
|
2481
|
+
shape.present++;
|
|
2482
|
+
shape.kinds.set(kind, (_nullishCoalesce(shape.kinds.get(kind), () => ( 0))) + 1);
|
|
2483
|
+
if (kind === "object") {
|
|
2484
|
+
shape.fields ??= /* @__PURE__ */ new Map();
|
|
2485
|
+
observeObject(shape.fields, value);
|
|
2486
|
+
} else if (kind === "array") {
|
|
2487
|
+
const arr = value;
|
|
2488
|
+
if (arr.length === 0) shape.sawEmptyArray = true;
|
|
2489
|
+
shape.elements ??= newShape();
|
|
2490
|
+
for (const el of arr) observe(shape.elements, el);
|
|
2491
|
+
}
|
|
2492
|
+
}
|
|
2493
|
+
function observeObject(fields, doc) {
|
|
2494
|
+
for (const [k, v] of Object.entries(doc)) {
|
|
2495
|
+
if (k.startsWith("$") || k.includes(".")) continue;
|
|
2496
|
+
let s = fields.get(k);
|
|
2497
|
+
if (!s) fields.set(k, s = newShape());
|
|
2498
|
+
observe(s, v);
|
|
2499
|
+
}
|
|
2500
|
+
}
|
|
2501
|
+
function fieldDef(name, shape, total, path3, ctx) {
|
|
2502
|
+
const kinds = [...shape.kinds.keys()];
|
|
2503
|
+
const required = total > 0 && shape.present === total;
|
|
2504
|
+
if (kinds.length === 0) {
|
|
2505
|
+
ctx.notes.push(`${path3}: always null in the sample \u2014 typed as any (object)`);
|
|
2506
|
+
return { type: "object" };
|
|
2507
|
+
}
|
|
2508
|
+
if (kinds.length > 1) {
|
|
2509
|
+
ctx.notes.push(`${path3}: mixed types (${kinds.sort().join(", ")}) \u2014 typed as any (object)`);
|
|
2510
|
+
return { type: "object", ...required && { required: true } };
|
|
2511
|
+
}
|
|
2512
|
+
const kind = kinds[0];
|
|
2513
|
+
if (kind === "other") {
|
|
2514
|
+
ctx.notes.push(`${path3}: a BSON type EFC doesn't model \u2014 typed as any (object)`);
|
|
2515
|
+
return { type: "object" };
|
|
2516
|
+
}
|
|
2517
|
+
if (kind === "object") {
|
|
2518
|
+
const sub = schemaOf(shape.fields, shape.present, path3, ctx);
|
|
2519
|
+
return required ? { type: "object", required: true, fields: sub } : sub;
|
|
2520
|
+
}
|
|
2521
|
+
if (kind === "array") {
|
|
2522
|
+
const el = shape.elements;
|
|
2523
|
+
const elKinds = [...el.kinds.keys()];
|
|
2524
|
+
if (elKinds.length === 1 && elKinds[0] === "object") {
|
|
2525
|
+
return [schemaOf(el.fields, el.present, `${path3}[]`, ctx)];
|
|
2526
|
+
}
|
|
2527
|
+
if (elKinds.length === 1 && elKinds[0] !== "array" && elKinds[0] !== "other") {
|
|
2528
|
+
const of = elKinds[0];
|
|
2529
|
+
return { type: "array", of, ...of === "objectId" && refFor(name, ctx) };
|
|
2530
|
+
}
|
|
2531
|
+
if (elKinds.length === 0) {
|
|
2532
|
+
ctx.notes.push(`${path3}: only empty arrays in the sample \u2014 element type unknown (object)`);
|
|
2533
|
+
} else {
|
|
2534
|
+
ctx.notes.push(`${path3}: array elements of mixed types \u2014 typed as any (object)`);
|
|
2535
|
+
}
|
|
2536
|
+
return { type: "array", of: "object" };
|
|
2537
|
+
}
|
|
2538
|
+
return {
|
|
2539
|
+
type: kind,
|
|
2540
|
+
...required && { required: true },
|
|
2541
|
+
...kind === "objectId" && refFor(name, ctx)
|
|
2542
|
+
};
|
|
2543
|
+
}
|
|
2544
|
+
function refFor(field, ctx) {
|
|
2545
|
+
const base = _chunkM53GODCXcjs.singular.call(void 0, field.replace(/_?[Ii][Dd]s?$/, "")).toLowerCase();
|
|
2546
|
+
const model = ctx.models.get(base);
|
|
2547
|
+
return model ? { ref: model } : {};
|
|
2548
|
+
}
|
|
2549
|
+
function schemaOf(fields, total, prefix, ctx) {
|
|
2550
|
+
const out = {};
|
|
2551
|
+
for (const [k, shape] of fields) {
|
|
2552
|
+
const def = fieldDef(k, shape, total, prefix ? `${prefix}.${k}` : k, ctx);
|
|
2553
|
+
if (def !== void 0) out[k] = def;
|
|
2554
|
+
}
|
|
2555
|
+
return out;
|
|
2556
|
+
}
|
|
2557
|
+
async function pullMongo(conn, pluralize, opts = {}) {
|
|
2558
|
+
const sampleSize = _nullishCoalesce(opts.sample, () => ( 1e3));
|
|
2559
|
+
const db = conn.db;
|
|
2560
|
+
const collections = (await db.listCollections({ type: "collection" }).toArray()).map((c) => c.name).filter((n) => !n.startsWith("system.") && !INTERNAL2.has(n)).sort();
|
|
2561
|
+
const nameOf2 = new Map(
|
|
2562
|
+
collections.map((c) => [c, _nullishCoalesce(_optionalChain([opts, 'access', _37 => _37.names, 'optionalAccess', _38 => _38.get, 'call', _39 => _39(c)]), () => ( (_chunkM53GODCXcjs.pascal.call(void 0, _chunkM53GODCXcjs.singular.call(void 0, c)) || "Model")))])
|
|
2563
|
+
);
|
|
2564
|
+
const ctxModels = new Map([...nameOf2.values()].map((m) => [m.toLowerCase(), m]));
|
|
2565
|
+
const models = [];
|
|
2566
|
+
const skipped = [];
|
|
2567
|
+
for (const collection of collections) {
|
|
2568
|
+
const name = nameOf2.get(collection);
|
|
2569
|
+
if (!/^[A-Za-z]/.test(name)) {
|
|
2570
|
+
skipped.push(collection);
|
|
2571
|
+
continue;
|
|
2572
|
+
}
|
|
2573
|
+
const coll = db.collection(collection);
|
|
2574
|
+
const docs = await coll.aggregate([{ $sample: { size: sampleSize } }], { promoteValues: false }).toArray();
|
|
2575
|
+
const ctx = { notes: [], models: ctxModels };
|
|
2576
|
+
const shapes = /* @__PURE__ */ new Map();
|
|
2577
|
+
for (const d of docs) observeObject(shapes, d);
|
|
2578
|
+
const idShape = shapes.get("_id");
|
|
2579
|
+
if (idShape && [...idShape.kinds.keys()].some((k) => k !== "objectId")) {
|
|
2580
|
+
ctx.notes.push(
|
|
2581
|
+
"_id is not an ObjectId here; defineCollection creates ObjectId ids for new documents"
|
|
2582
|
+
);
|
|
2583
|
+
}
|
|
2584
|
+
shapes.delete("_id");
|
|
2585
|
+
shapes.delete("__v");
|
|
2586
|
+
const isDate = (k) => {
|
|
2587
|
+
const s = shapes.get(k);
|
|
2588
|
+
return !!s && s.kinds.size === 1 && s.kinds.has("date");
|
|
2589
|
+
};
|
|
2590
|
+
const options = {};
|
|
2591
|
+
if (isDate("createdAt") && isDate("updatedAt")) {
|
|
2592
|
+
shapes.delete("createdAt");
|
|
2593
|
+
shapes.delete("updatedAt");
|
|
2594
|
+
} else {
|
|
2595
|
+
options["timestamps"] = false;
|
|
2596
|
+
}
|
|
2597
|
+
const fields = Object.entries(schemaOf(shapes, docs.length, "", ctx));
|
|
2598
|
+
for (const [field, def] of fields) {
|
|
2599
|
+
const d = def;
|
|
2600
|
+
const holdsIds = d["type"] === "objectId" || d["type"] === "array" && d["of"] === "objectId";
|
|
2601
|
+
if (!holdsIds || d["ref"] !== void 0) continue;
|
|
2602
|
+
const ids = /* @__PURE__ */ new Map();
|
|
2603
|
+
for (const doc of docs) {
|
|
2604
|
+
for (const v of [doc[field]].flat()) {
|
|
2605
|
+
if (bsonKind(v) === "objectId" && ids.size < 20) ids.set(String(v), v);
|
|
2606
|
+
}
|
|
2607
|
+
}
|
|
2608
|
+
if (ids.size === 0) continue;
|
|
2609
|
+
const holders = [];
|
|
2610
|
+
for (const other of collections) {
|
|
2611
|
+
const found = await db.collection(other).countDocuments({ _id: { $in: [...ids.values()] } });
|
|
2612
|
+
if (found === ids.size) holders.push(other);
|
|
2613
|
+
}
|
|
2614
|
+
if (holders.length === 1) d["ref"] = nameOf2.get(holders[0]);
|
|
2615
|
+
else
|
|
2616
|
+
ctx.notes.push(
|
|
2617
|
+
`${field}: holds ObjectIds${holders.length ? ` found in ${holders.join(", ")}` : ""} \u2014 add ref: '<Model>' if it points at another collection`
|
|
2618
|
+
);
|
|
2619
|
+
}
|
|
2620
|
+
const indexes = [];
|
|
2621
|
+
for (const ix of await coll.indexes()) {
|
|
2622
|
+
if (ix["name"] === "_id_") continue;
|
|
2623
|
+
const key = ix["key"];
|
|
2624
|
+
const textKeys = ix["weights"] ? Object.keys(ix["weights"]) : [];
|
|
2625
|
+
const spec = textKeys.length ? Object.fromEntries(textKeys.map((k) => [k, "text"])) : key;
|
|
2626
|
+
const keys = Object.keys(spec);
|
|
2627
|
+
const simple = keys.length === 1 && ix["partialFilterExpression"] === void 0 && ix["expireAfterSeconds"] === void 0 && !keys[0].includes(".");
|
|
2628
|
+
const field = simple ? fields.find(([f]) => f === keys[0]) : void 0;
|
|
2629
|
+
if (field && !Array.isArray(field[1]) && typeof field[1]["type"] === "string") {
|
|
2630
|
+
const def = field[1];
|
|
2631
|
+
const dir = spec[keys[0]];
|
|
2632
|
+
if (ix["unique"]) def["unique"] = true;
|
|
2633
|
+
else def["index"] = dir === "2dsphere" || dir === "text" || dir === "hashed" ? dir : true;
|
|
2634
|
+
continue;
|
|
2635
|
+
}
|
|
2636
|
+
indexes.push({
|
|
2637
|
+
fields: spec,
|
|
2638
|
+
...ix["unique"] === true && { unique: true },
|
|
2639
|
+
...ix["partialFilterExpression"] !== void 0 && {
|
|
2640
|
+
partialFilterExpression: ix["partialFilterExpression"]
|
|
2641
|
+
},
|
|
2642
|
+
...ix["expireAfterSeconds"] !== void 0 && {
|
|
2643
|
+
expireAfterSeconds: ix["expireAfterSeconds"]
|
|
2644
|
+
}
|
|
2645
|
+
});
|
|
2646
|
+
}
|
|
2647
|
+
if (indexes.length) options["indexes"] = indexes;
|
|
2648
|
+
if (pluralize(name) !== collection) options["collection"] = collection;
|
|
2649
|
+
ctx.notes.unshift(
|
|
2650
|
+
docs.length ? `Pulled from ${docs.length} sampled document(s) of "${collection}": a field is required only when every sample had a value.` : `"${collection}" is empty \u2014 no fields could be inferred.`
|
|
2651
|
+
);
|
|
2652
|
+
models.push({
|
|
2653
|
+
name,
|
|
2654
|
+
fields,
|
|
2655
|
+
options,
|
|
2656
|
+
notes: ctx.notes,
|
|
2657
|
+
api: "defineCollection",
|
|
2658
|
+
table: collection
|
|
2659
|
+
});
|
|
2660
|
+
}
|
|
2661
|
+
return { models, skipped };
|
|
2662
|
+
}
|
|
2663
|
+
|
|
772
2664
|
// src/cli/db-runner.ts
|
|
773
2665
|
async function importModels(root) {
|
|
774
2666
|
const files = [];
|
|
@@ -784,7 +2676,28 @@ async function importModels(root) {
|
|
|
784
2676
|
walk(_path2.default.join(root, "model"));
|
|
785
2677
|
walk(_path2.default.join(root, "models"));
|
|
786
2678
|
for (const f of files.sort()) await Promise.resolve().then(() => _interopRequireWildcard(require(_url.pathToFileURL.call(void 0, f).href)));
|
|
787
|
-
return
|
|
2679
|
+
return _chunkIUZ6A7PBcjs.registeredModels.call(void 0, );
|
|
2680
|
+
}
|
|
2681
|
+
async function existingModels(dir) {
|
|
2682
|
+
const out = /* @__PURE__ */ new Map();
|
|
2683
|
+
if (!_fs2.default.existsSync(dir)) return out;
|
|
2684
|
+
const files = _fs2.default.readdirSync(dir).filter((f) => /\.(ts|js|mts|mjs)$/.test(f) && !f.endsWith(".d.ts")).sort((a, b) => Number(/^index\./.test(a)) - Number(/^index\./.test(b)) || a.localeCompare(b));
|
|
2685
|
+
const fileOf = /* @__PURE__ */ new Map();
|
|
2686
|
+
for (const f of files) {
|
|
2687
|
+
const file = _path2.default.join(dir, f);
|
|
2688
|
+
try {
|
|
2689
|
+
await Promise.resolve().then(() => _interopRequireWildcard(require(_url.pathToFileURL.call(void 0, file).href)));
|
|
2690
|
+
} catch (err) {
|
|
2691
|
+
console.log(_picocolors2.default.yellow(` ! ${f} didn't load (${err.message.split("\n")[0]})`));
|
|
2692
|
+
continue;
|
|
2693
|
+
}
|
|
2694
|
+
for (const m of _chunkIUZ6A7PBcjs.registeredModels.call(void 0, )) if (!fileOf.has(m.name)) fileOf.set(m.name, file);
|
|
2695
|
+
}
|
|
2696
|
+
for (const m of _chunkIUZ6A7PBcjs.registeredModels.call(void 0, )) {
|
|
2697
|
+
const storage = await _optionalChain([m, 'access', _40 => _40.studio, 'optionalAccess', _41 => _41.storage, 'call', _42 => _42(), 'access', _43 => _43.catch, 'call', _44 => _44(() => void 0)]);
|
|
2698
|
+
if (storage && !out.has(storage)) out.set(storage, { name: m.name, file: fileOf.get(m.name) });
|
|
2699
|
+
}
|
|
2700
|
+
return out;
|
|
788
2701
|
}
|
|
789
2702
|
function shadowUrl(url, engine, name) {
|
|
790
2703
|
if (engine === "mongodb")
|
|
@@ -809,17 +2722,17 @@ function engineOf(url) {
|
|
|
809
2722
|
async function main() {
|
|
810
2723
|
const [command, raw] = process.argv.slice(2);
|
|
811
2724
|
const opts = JSON.parse(_nullishCoalesce(raw, () => ( "{}")));
|
|
812
|
-
|
|
2725
|
+
_chunkJP36TLL4cjs.configureLogger.call(void 0, { level: "warn" });
|
|
813
2726
|
const url = _nullishCoalesce(opts.databaseUrl, () => ( process.env["DATABASE_URL"]));
|
|
814
2727
|
if (!url)
|
|
815
2728
|
throw new Error("[EFC] DATABASE_URL is not set (add it to .env or pass --database-url)");
|
|
816
2729
|
const engine = engineOf(url);
|
|
817
|
-
|
|
818
|
-
let client = engine === "mongodb" ? await
|
|
819
|
-
|
|
2730
|
+
_chunkIUZ6A7PBcjs.setDbEngine.call(void 0, engine);
|
|
2731
|
+
let client = engine === "mongodb" ? await _chunkR2K7AFIBcjs.connectMongo.call(void 0, url) : await _chunkJP36TLL4cjs.connectPostgres.call(void 0, url);
|
|
2732
|
+
_chunkR2K7AFIBcjs.setDbClient.call(void 0, client);
|
|
820
2733
|
const close = async () => {
|
|
821
2734
|
if (engine === "mongodb") await client.close();
|
|
822
|
-
else await
|
|
2735
|
+
else await _chunkJP36TLL4cjs.closePostgres.call(void 0, );
|
|
823
2736
|
};
|
|
824
2737
|
const migrations = _path2.default.join(opts.root, "migrations");
|
|
825
2738
|
const step = (verb) => (name) => console.log(` ${_picocolors2.default.cyan(verb)} ${name}`);
|
|
@@ -852,7 +2765,7 @@ async function main() {
|
|
|
852
2765
|
break;
|
|
853
2766
|
}
|
|
854
2767
|
case "sync": {
|
|
855
|
-
|
|
2768
|
+
_chunkIUZ6A7PBcjs.setAutoSync.call(void 0, false);
|
|
856
2769
|
const models = await importModels(opts.root);
|
|
857
2770
|
if (models.length === 0) {
|
|
858
2771
|
console.log(
|
|
@@ -887,16 +2800,16 @@ async function main() {
|
|
|
887
2800
|
);
|
|
888
2801
|
}
|
|
889
2802
|
await close();
|
|
890
|
-
client = engine === "mongodb" ? await
|
|
891
|
-
|
|
2803
|
+
client = engine === "mongodb" ? await _chunkR2K7AFIBcjs.connectMongo.call(void 0, shadowUrl(url, engine, shadow)) : await _chunkJP36TLL4cjs.connectPostgres.call(void 0, shadowUrl(url, engine, shadow));
|
|
2804
|
+
_chunkR2K7AFIBcjs.setDbClient.call(void 0, client);
|
|
892
2805
|
try {
|
|
893
|
-
|
|
2806
|
+
_chunkIUZ6A7PBcjs.setAutoSync.call(void 0, false);
|
|
894
2807
|
const migrator = new Migrator(migrations, engine, client);
|
|
895
|
-
|
|
2808
|
+
_chunkIUZ6A7PBcjs.setSyncSuppressed.call(void 0, true);
|
|
896
2809
|
try {
|
|
897
2810
|
await migrator.migrate();
|
|
898
2811
|
} finally {
|
|
899
|
-
|
|
2812
|
+
_chunkIUZ6A7PBcjs.setSyncSuppressed.call(void 0, false);
|
|
900
2813
|
}
|
|
901
2814
|
const models = await importModels(opts.root);
|
|
902
2815
|
if (models.length === 0) {
|
|
@@ -979,19 +2892,30 @@ async function main() {
|
|
|
979
2892
|
break;
|
|
980
2893
|
}
|
|
981
2894
|
case "pull": {
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
const { models, skipped: notPulled } = await pullPostgres(client)
|
|
2895
|
+
_chunkIUZ6A7PBcjs.setAutoSync.call(void 0, false);
|
|
2896
|
+
const dir = _path2.default.resolve(process.cwd(), _nullishCoalesce(opts.out, () => ( _path2.default.join("src", "model"))));
|
|
2897
|
+
const existing = await existingModels(dir);
|
|
2898
|
+
const names = new Map([...existing].map(([table, m]) => [table, m.name]));
|
|
2899
|
+
const { models, skipped: notPulled } = engine === "postgresql" ? await pullPostgres(client, names) : await pullMongo(
|
|
2900
|
+
client,
|
|
2901
|
+
(await _chunkR2K7AFIBcjs.loadMongoose.call(void 0, )).pluralize(),
|
|
2902
|
+
{
|
|
2903
|
+
...opts.sample !== void 0 && { sample: opts.sample },
|
|
2904
|
+
names
|
|
2905
|
+
}
|
|
2906
|
+
);
|
|
987
2907
|
if (models.length === 0) {
|
|
988
|
-
console.log(
|
|
2908
|
+
console.log(
|
|
2909
|
+
_picocolors2.default.yellow(
|
|
2910
|
+
engine === "postgresql" ? " No tables found in the current schema" : " No collections found in the database"
|
|
2911
|
+
)
|
|
2912
|
+
);
|
|
989
2913
|
break;
|
|
990
2914
|
}
|
|
991
2915
|
const typescript = _fs2.default.existsSync(_path2.default.join(process.cwd(), "tsconfig.json"));
|
|
992
|
-
const
|
|
993
|
-
const { written, skipped } = _chunkQL6EWT4Bcjs.writeModels.call(void 0, dir, models, {
|
|
2916
|
+
const { written, skipped } = _chunkM53GODCXcjs.writeModels.call(void 0, dir, models, {
|
|
994
2917
|
typescript,
|
|
2918
|
+
existing,
|
|
995
2919
|
...opts.force && { force: true }
|
|
996
2920
|
});
|
|
997
2921
|
console.log(_picocolors2.default.bold(`
|
|
@@ -999,15 +2923,16 @@ async function main() {
|
|
|
999
2923
|
`));
|
|
1000
2924
|
for (const f of written)
|
|
1001
2925
|
console.log(` ${_picocolors2.default.green("+")} ${_path2.default.relative(process.cwd(), f)}`);
|
|
1002
|
-
for (const
|
|
2926
|
+
for (const { file, reason } of skipped)
|
|
1003
2927
|
console.log(
|
|
1004
|
-
` ${_picocolors2.default.yellow("\u2022")} ${_path2.default.relative(process.cwd(),
|
|
2928
|
+
` ${_picocolors2.default.yellow("\u2022")} ${_path2.default.relative(process.cwd(), file)} ${_picocolors2.default.dim(reason)}`
|
|
1005
2929
|
);
|
|
1006
2930
|
if (notPulled.length)
|
|
1007
2931
|
console.log(
|
|
1008
2932
|
_picocolors2.default.dim(
|
|
1009
|
-
`
|
|
1010
|
-
Not pulled (no single "id" primary key of type uuid, integer or bigint): ${notPulled.join(", ")}`
|
|
2933
|
+
engine === "postgresql" ? `
|
|
2934
|
+
Not pulled (no single "id" primary key of type uuid, integer or bigint): ${notPulled.join(", ")}` : `
|
|
2935
|
+
Not pulled (no usable model name): ${notPulled.join(", ")}`
|
|
1011
2936
|
)
|
|
1012
2937
|
);
|
|
1013
2938
|
const notes = models.reduce((n, m) => n + m.notes.length, 0);
|
|
@@ -1048,12 +2973,20 @@ async function main() {
|
|
|
1048
2973
|
break;
|
|
1049
2974
|
}
|
|
1050
2975
|
case "studio": {
|
|
1051
|
-
const
|
|
2976
|
+
const models = opts.write ? await importModels(opts.root) : [];
|
|
2977
|
+
const { url: studioUrl } = await startStudio(engine, client, _nullishCoalesce(opts.port, () => ( 4983)), {
|
|
2978
|
+
write: !!opts.write,
|
|
2979
|
+
models
|
|
2980
|
+
});
|
|
1052
2981
|
console.log(
|
|
1053
2982
|
`
|
|
1054
|
-
${_picocolors2.default.bold("EFC Studio")} ${_picocolors2.default.dim(`(${engine}, read-only)`)} ${_picocolors2.default.cyan(studioUrl)}
|
|
2983
|
+
${_picocolors2.default.bold("EFC Studio")} ${_picocolors2.default.dim(`(${engine}, ${opts.write ? `write \u2014 ${models.length} model(s)` : "read-only"})`)} ${_picocolors2.default.cyan(studioUrl)}
|
|
1055
2984
|
`
|
|
1056
2985
|
);
|
|
2986
|
+
if (opts.write)
|
|
2987
|
+
console.log(
|
|
2988
|
+
_picocolors2.default.yellow(" Writes change real data. Point DATABASE_URL at a development database.\n")
|
|
2989
|
+
);
|
|
1057
2990
|
await new Promise((resolve) => {
|
|
1058
2991
|
process.once("SIGINT", resolve);
|
|
1059
2992
|
process.once("SIGTERM", resolve);
|