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