@kedem/okdb 1.0.1 → 1.0.4
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/bin/okdb.js +1 -1
- package/keys/public.pem +3 -0
- package/okdb.js +1 -1
- package/package.json +2 -2
- package/public/admin-app.js +1 -1
- package/public/components/admin-route-host.ok.js +1 -1
- package/public/components/env-picker.ok.js +1 -1
- package/public/components/field-path-input.ok.js +1 -1
- package/public/components/field.html +154 -2
- package/public/components/geo-map.ok.js +1 -1
- package/public/components/ok-cron-input.ok.js +1 -1
- package/public/components/ok-dropzone.ok.js +1 -1
- package/public/components/ok-js-input.ok.js +1 -1
- package/public/components/ok-json-input.ok.js +1 -1
- package/public/components/ok-text-monaco-input.ok.js +1 -1
- package/public/components/theme-toggle.ok.js +1 -1
- package/public/index.html +29 -2
- package/public/layouts/_default.ok.html +1 -1
- package/public/layouts/okdb-cube.ok.html +1 -1
- package/public/login-app.js +1 -1
- package/public/login.html +205 -1
- package/public/modules/ok.js +1 -1
- package/public/sections/api/index.ok.html +1 -1
- package/public/sections/api/parts/api-endpoint.ok.js +1 -1
- package/public/sections/auth/index.ok.html +1 -1
- package/public/sections/auth/modals/create-token-modal.ok.js +1 -1
- package/public/sections/auth/modals/edit-token-modal.ok.js +1 -1
- package/public/sections/auth/modals/perm-info-popover.ok.js +1 -1
- package/public/sections/auth/parts/token-detail.ok.js +1 -1
- package/public/sections/auth/parts/token-list.ok.js +1 -1
- package/public/sections/db/index.ok.html +1 -1
- package/public/sections/db/modals/add-item-modal.ok.js +1 -1
- package/public/sections/db/modals/create-env-modal.ok.js +1 -1
- package/public/sections/db/modals/create-fts-modal.ok.js +1 -1
- package/public/sections/db/modals/create-index-modal.ok.js +1 -1
- package/public/sections/db/modals/create-pipeline-modal.ok.js +1 -1
- package/public/sections/db/modals/demo-env-modal.ok.js +1 -1
- package/public/sections/db/modals/remove-env-modal.ok.js +1 -1
- package/public/sections/db/modals/schema-edit-modal.ok.js +1 -1
- package/public/sections/db/parts/db-overview.ok.js +1 -1
- package/public/sections/db/parts/db-pipelines-panel.ok.js +1 -1
- package/public/sections/db/parts/edit-row.ok.js +1 -1
- package/public/sections/db/parts/tm-timeline.ok.js +1 -1
- package/public/sections/db/parts/type-changelog.ok.js +1 -1
- package/public/sections/db/parts/type-list.ok.js +1 -1
- package/public/sections/db/parts/type-pipelines-tab.ok.js +1 -1
- package/public/sections/db/parts/type-schema-tab.ok.js +1 -1
- package/public/sections/db/parts/type-viewer.ok.js +1 -1
- package/public/sections/db/parts/type-violations-tab.ok.js +1 -1
- package/public/sections/docs/index.ok.html +1 -1
- package/public/sections/embeddings/index.ok.html +1 -1
- package/public/sections/embeddings/modals/register-model-modal.ok.js +1 -1
- package/public/sections/embeddings/parts/embed-create-panel.ok.js +1 -1
- package/public/sections/embeddings/parts/embed-embedder-panel.ok.js +1 -1
- package/public/sections/embeddings/parts/embed-engine-declaration-editor.ok.js +1 -1
- package/public/sections/embeddings/parts/embed-engine-list.ok.js +1 -1
- package/public/sections/embeddings/parts/embed-indexer-panel.ok.js +1 -1
- package/public/sections/embeddings/parts/embed-lifecycle-bar.ok.js +1 -1
- package/public/sections/embeddings/parts/embed-model-catalog.ok.js +1 -1
- package/public/sections/embeddings/parts/embed-overview.ok.js +1 -1
- package/public/sections/embeddings/parts/embed-search-panel.ok.js +1 -1
- package/public/sections/embeddings/parts/embed-worker-panel.ok.js +1 -1
- package/public/sections/embeddings/parts/embeddings-engine-panel.ok.js +1 -1
- package/public/sections/embeddings/parts/engines-overview.ok.js +1 -1
- package/public/sections/embeddings/parts/pipeline-create-panel.ok.js +1 -1
- package/public/sections/engines/engine-panel-shared-style.js +1 -1
- package/public/sections/engines/engine-ui-utils.js +1 -1
- package/public/sections/engines/index.ok.html +1 -1
- package/public/sections/engines/modals/engine-modal.ok.js +1 -1
- package/public/sections/engines/parts/engine-declaration-editor.ok.js +1 -1
- package/public/sections/engines/parts/engine-lifecycle-actions.ok.js +1 -1
- package/public/sections/engines/parts/engine-panel-shell.ok.js +1 -1
- package/public/sections/engines/parts/engine-resource-card.ok.js +1 -1
- package/public/sections/engines/parts/engine-row-item.ok.js +1 -1
- package/public/sections/engines/parts/generic-engine-panel.ok.js +1 -1
- package/public/sections/files/index.ok.html +1 -1
- package/public/sections/files/parts/files-blob-status.ok.js +1 -1
- package/public/sections/files/parts/files-collection-list.ok.js +1 -1
- package/public/sections/files/parts/files-collection-panel.ok.js +1 -1
- package/public/sections/files/parts/files-file-list.ok.js +1 -1
- package/public/sections/files/parts/files-overview.ok.js +1 -1
- package/public/sections/files/parts/files-path-browser.ok.js +1 -1
- package/public/sections/files/parts/files-upload-panel.ok.js +1 -1
- package/public/sections/functions/index.ok.html +1 -1
- package/public/sections/functions/modals/function-modal.ok.js +1 -1
- package/public/sections/functions/parts/function-detail.ok.js +1 -1
- package/public/sections/functions/parts/function-logs.ok.js +1 -1
- package/public/sections/functions/parts/function-runner.ok.js +1 -1
- package/public/sections/functions/parts/functions-list.ok.js +1 -1
- package/public/sections/license/index.ok.html +1 -1
- package/public/sections/license/parts/license-panel.ok.js +1 -1
- package/public/sections/processors/index.ok.html +1 -1
- package/public/sections/queue/index.ok.html +1 -1
- package/public/sections/queue/modals/create-bucket-modal.ok.js +1 -1
- package/public/sections/queue/modals/edit-bucket-modal.ok.js +1 -1
- package/public/sections/queue/modals/edit-job-modal.ok.js +1 -1
- package/public/sections/queue/modals/enqueue-job-modal.ok.js +1 -1
- package/public/sections/queue/modals/job-type-modal.ok.js +1 -1
- package/public/sections/queue/parts/ok-job-form.ok.js +1 -1
- package/public/sections/queue/parts/queue-buckets.ok.js +1 -1
- package/public/sections/queue/parts/queue-job-types.ok.js +1 -1
- package/public/sections/queue/parts/queue-jobs.ok.js +1 -1
- package/public/sections/queue/parts/queue-types.ok.js +1 -1
- package/public/sections/queue/parts/queue-workers.ok.js +1 -1
- package/public/sections/sync/index.ok.html +1 -1
- package/public/sections/sync/parts/sync-node-detail.ok.js +1 -1
- package/public/sections/sync/parts/sync-retention.ok.js +1 -1
- package/public/sections/sync/parts/sync-topology.ok.js +1 -1
- package/public/sections/system/index.ok.html +1 -1
- package/public/sections/system/modals/data-ops-modal.ok.js +1 -1
- package/public/sections/system/parts/system-api-panel.ok.js +1 -1
- package/public/sections/system/parts/system-auth-panel.ok.js +1 -1
- package/public/sections/system/parts/system-log-history.ok.js +1 -1
- package/public/sections/system/parts/system-log.ok.js +1 -1
- package/public/sections/system/parts/system-status.ok.js +1 -1
- package/public/sections/system/parts/system-sync-panel.ok.js +1 -1
- package/public/sections/views/index.ok.html +1 -1
- package/public/sections/views/modals/create-view-modal.ok.js +1 -1
- package/public/sections/views/parts/view-detail.ok.js +1 -1
- package/public/sections/views/parts/views-list.ok.js +1 -1
- package/public/sections/views/parts/views-overview.ok.js +1 -1
- package/public/setup-app.js +1 -1
- package/public/setup.html +189 -1
- package/public/stores/auth-store.js +1 -1
- package/public/stores/events-store.js +1 -1
- package/public/stores/functions-store.js +1 -1
- package/public/stores/okdb-store.js +1 -1
- package/public/stores/theme-store.js +1 -1
- package/public/test-cron-input.html +53 -3
- package/public/test-json-input.html +182 -3
- package/public/util/permissions.js +1 -1
- package/public/util/sift-schema.js +1 -1
- package/public/vendor/okjs/ok.esm.min.js +1 -2
- package/public/view-models/type-query-vm.js +1 -1
- package/okdb-data/default/data.mdb +0 -0
- package/okdb-data/default/lock.mdb +0 -0
- package/okdb-data/~log/data.mdb +0 -0
- package/okdb-data/~log/lock.mdb +0 -0
- package/okdb-data/~system/data.mdb +0 -0
- package/okdb-data/~system/lock.mdb +0 -0
- package/public/images/logo.png +0 -0
- package/public/images/logo.svg +0 -333
package/public/setup.html
CHANGED
|
@@ -1 +1,189 @@
|
|
|
1
|
-
<!DOCTYPE html
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html lang="en">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="UTF-8">
|
|
5
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
6
|
+
<link rel="icon" type="image/png" href="favicon.ico">
|
|
7
|
+
<link rel="apple-touch-icon" sizes="180x180" href="apple-touch-icon.png">
|
|
8
|
+
<link rel="icon" type="image/png" sizes="32x32" href="favicon-32x32.png">
|
|
9
|
+
<link rel="icon" type="image/png" sizes="16x16" href="favicon-16x16.png">
|
|
10
|
+
<link rel="manifest" href="site.webmanifest">
|
|
11
|
+
<title>OKDB Setup</title>
|
|
12
|
+
<script>
|
|
13
|
+
(function () {
|
|
14
|
+
try {
|
|
15
|
+
var saved = localStorage.getItem('okdbTheme');
|
|
16
|
+
if (saved !== 'dark' && saved !== 'light') {
|
|
17
|
+
saved = window.matchMedia && window.matchMedia('(prefers-color-scheme: light)').matches ? 'light' : 'dark';
|
|
18
|
+
}
|
|
19
|
+
if (saved === 'light') document.documentElement.setAttribute('data-theme', 'light');
|
|
20
|
+
} catch (e) { /* localStorage blocked — default to dark */ }
|
|
21
|
+
})();
|
|
22
|
+
</script>
|
|
23
|
+
<style>
|
|
24
|
+
:root {
|
|
25
|
+
color-scheme: dark;
|
|
26
|
+
--bg0:#071018;
|
|
27
|
+
--bg1:#0d1722;
|
|
28
|
+
--bg2:#142235;
|
|
29
|
+
--line:#27415f;
|
|
30
|
+
--text:#e8f2ff;
|
|
31
|
+
--muted:#9ab2cc;
|
|
32
|
+
--accent:#4fc1ff;
|
|
33
|
+
--accent2:#7ee787;
|
|
34
|
+
}
|
|
35
|
+
:root[data-theme='light'] {
|
|
36
|
+
color-scheme: light;
|
|
37
|
+
--bg0:#dce8f5;
|
|
38
|
+
--bg1:#f0f6fc;
|
|
39
|
+
--bg2:#ffffff;
|
|
40
|
+
--line:#b0c8e0;
|
|
41
|
+
--text:#0d1a28;
|
|
42
|
+
--muted:#3a5870;
|
|
43
|
+
--accent:#1a7ab8;
|
|
44
|
+
--accent2:#16a34a;
|
|
45
|
+
}
|
|
46
|
+
* { box-sizing:border-box; }
|
|
47
|
+
body {
|
|
48
|
+
margin:0;
|
|
49
|
+
min-height:100vh;
|
|
50
|
+
font-family: Inter, Segoe UI, Arial, sans-serif;
|
|
51
|
+
color:var(--text);
|
|
52
|
+
background: radial-gradient(circle at top, #16304b 0%, var(--bg0) 45%, #05090f 100%);
|
|
53
|
+
display:flex;
|
|
54
|
+
align-items:center;
|
|
55
|
+
justify-content:center;
|
|
56
|
+
padding:24px;
|
|
57
|
+
}
|
|
58
|
+
[data-theme='light'] body {
|
|
59
|
+
background: radial-gradient(circle at top, #c8dff5 0%, var(--bg0) 45%, #e8f2ff 100%);
|
|
60
|
+
}
|
|
61
|
+
.shell {
|
|
62
|
+
width:min(1000px, 100%);
|
|
63
|
+
display:flex;
|
|
64
|
+
flex-direction:column;
|
|
65
|
+
gap:0;
|
|
66
|
+
}
|
|
67
|
+
.header {
|
|
68
|
+
margin-bottom:28px;
|
|
69
|
+
text-align:center;
|
|
70
|
+
}
|
|
71
|
+
.eyebrow {
|
|
72
|
+
display:inline-flex; align-items:center; gap:8px; padding:6px 10px; border-radius:999px;
|
|
73
|
+
background:rgba(79,193,255,.12); color:var(--accent); font-size:12px; letter-spacing:.08em; text-transform:uppercase;
|
|
74
|
+
border:1px solid rgba(79,193,255,.18);
|
|
75
|
+
}
|
|
76
|
+
h1 { font-size:32px; line-height:1.1; margin:14px 0 6px; }
|
|
77
|
+
.subtitle { color:var(--muted); font-size:15px; margin:0; }
|
|
78
|
+
.panels {
|
|
79
|
+
display:grid;
|
|
80
|
+
grid-template-columns:1fr 1fr;
|
|
81
|
+
gap:16px;
|
|
82
|
+
}
|
|
83
|
+
.panel {
|
|
84
|
+
background:rgba(8,16,26,.86);
|
|
85
|
+
border:1px solid rgba(79,193,255,.16);
|
|
86
|
+
border-radius:18px;
|
|
87
|
+
padding:28px;
|
|
88
|
+
backdrop-filter: blur(10px);
|
|
89
|
+
display:flex;
|
|
90
|
+
flex-direction:column;
|
|
91
|
+
gap:20px;
|
|
92
|
+
}
|
|
93
|
+
.panel-title { font-size:17px; font-weight:700; margin:0; }
|
|
94
|
+
.panel-desc { font-size:13px; color:var(--muted); margin:0; line-height:1.55; }
|
|
95
|
+
.stack { display:flex; flex-direction:column; gap:12px; }
|
|
96
|
+
.field { display:flex; flex-direction:column; gap:6px; }
|
|
97
|
+
.field label { font-size:12px; color:var(--muted); }
|
|
98
|
+
.field input {
|
|
99
|
+
width:100%; background:#0b1420; color:var(--text); border:1px solid rgba(255,255,255,.08);
|
|
100
|
+
border-radius:12px; padding:12px 14px; outline:none; font-size:14px;
|
|
101
|
+
}
|
|
102
|
+
.field input:focus { border-color: rgba(79,193,255,.45); box-shadow:0 0 0 3px rgba(79,193,255,.12); }
|
|
103
|
+
.button {
|
|
104
|
+
display:inline-flex; align-items:center; justify-content:center;
|
|
105
|
+
width:100%; border:none; cursor:pointer; font-family:inherit; font-weight:700; font-size:15px;
|
|
106
|
+
border-radius:12px; padding:14px 16px; background:linear-gradient(135deg, var(--accent), #8fdcff);
|
|
107
|
+
color:#04111f; box-shadow:0 10px 30px rgba(79,193,255,.22);
|
|
108
|
+
}
|
|
109
|
+
.button:hover { filter:brightness(1.04); }
|
|
110
|
+
.button.green {
|
|
111
|
+
background:linear-gradient(135deg, var(--accent2), #a8f0b4);
|
|
112
|
+
box-shadow:0 10px 30px rgba(126,231,135,.18);
|
|
113
|
+
}
|
|
114
|
+
.error {
|
|
115
|
+
padding:10px 12px; border-radius:10px;
|
|
116
|
+
background:rgba(248,113,113,.12); border:1px solid rgba(248,113,113,.25); color:#fecaca;
|
|
117
|
+
font-size:13px;
|
|
118
|
+
}
|
|
119
|
+
.success {
|
|
120
|
+
padding:10px 12px; border-radius:10px;
|
|
121
|
+
background:rgba(126,231,135,.1); border:1px solid rgba(126,231,135,.25); color:#a8f0b4;
|
|
122
|
+
font-size:13px;
|
|
123
|
+
}
|
|
124
|
+
@media (max-width:720px) {
|
|
125
|
+
.panels { grid-template-columns:1fr; }
|
|
126
|
+
}
|
|
127
|
+
[data-theme='light'] .panel { background: rgba(255,255,255,.92); border-color: rgba(26,122,184,.2); }
|
|
128
|
+
[data-theme='light'] .field input { background: var(--bg2); border-color: var(--line); }
|
|
129
|
+
</style>
|
|
130
|
+
</head>
|
|
131
|
+
<body>
|
|
132
|
+
<main class="shell">
|
|
133
|
+
<header class="header">
|
|
134
|
+
<div class="eyebrow">OKDB First-Time Setup</div>
|
|
135
|
+
<h1>Welcome to OKDB</h1>
|
|
136
|
+
<p class="subtitle">This node has no credentials yet. Create an admin token or join an existing cluster.</p>
|
|
137
|
+
</header>
|
|
138
|
+
|
|
139
|
+
<div class="panels">
|
|
140
|
+
<section class="panel" id="createPanel">
|
|
141
|
+
<div>
|
|
142
|
+
<p class="panel-title">Create first admin token</p>
|
|
143
|
+
<p class="panel-desc">Set up credentials for this node. You'll log in with these after setup.</p>
|
|
144
|
+
</div>
|
|
145
|
+
<form id="createForm" class="stack">
|
|
146
|
+
<div class="field">
|
|
147
|
+
<label for="createName">Username</label>
|
|
148
|
+
<input id="createName" name="name" value="admin" autocomplete="username" placeholder="admin">
|
|
149
|
+
</div>
|
|
150
|
+
<div class="field">
|
|
151
|
+
<label for="createPassword">Password</label>
|
|
152
|
+
<input id="createPassword" name="password" type="password" autocomplete="new-password" placeholder="••••••••">
|
|
153
|
+
</div>
|
|
154
|
+
<div class="field">
|
|
155
|
+
<label for="createConfirm">Confirm password</label>
|
|
156
|
+
<input id="createConfirm" name="confirm" type="password" autocomplete="new-password" placeholder="••••••••">
|
|
157
|
+
</div>
|
|
158
|
+
<div class="field">
|
|
159
|
+
<label for="createLabel">Label <span style="color:var(--muted)">(optional)</span></label>
|
|
160
|
+
<input id="createLabel" name="label" value="Initial admin" placeholder="Initial admin">
|
|
161
|
+
</div>
|
|
162
|
+
<div id="createError" class="error" hidden></div>
|
|
163
|
+
<button type="submit" class="button">Create admin and continue</button>
|
|
164
|
+
</form>
|
|
165
|
+
</section>
|
|
166
|
+
|
|
167
|
+
<section class="panel" id="joinPanel">
|
|
168
|
+
<div>
|
|
169
|
+
<p class="panel-title">Join an existing cluster</p>
|
|
170
|
+
<p class="panel-desc">Connect to a running OKDB node. The cluster admin provides the sync token out-of-band.</p>
|
|
171
|
+
</div>
|
|
172
|
+
<form id="joinForm" class="stack">
|
|
173
|
+
<div class="field">
|
|
174
|
+
<label for="joinAddress">Remote node address</label>
|
|
175
|
+
<input id="joinAddress" name="address" placeholder="https://node-a.example.com:8484">
|
|
176
|
+
</div>
|
|
177
|
+
<div class="field">
|
|
178
|
+
<label for="joinToken">Cluster sync token</label>
|
|
179
|
+
<input id="joinToken" name="token" type="password" placeholder="cluster sync token">
|
|
180
|
+
</div>
|
|
181
|
+
<div id="joinError" class="error" hidden></div>
|
|
182
|
+
<button type="submit" class="button green">Join cluster</button>
|
|
183
|
+
</form>
|
|
184
|
+
</section>
|
|
185
|
+
</div>
|
|
186
|
+
</main>
|
|
187
|
+
<script type="module" src="setup-app.js"></script>
|
|
188
|
+
</body>
|
|
189
|
+
</html>
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
import{ok as s}from"../modules/ok.js";import{hasPermission as e,setImpliedBy as t}from"../util/permissions.js";export default s.proxy({config:null,session:null,catalog:null,loading:!1,error:null,notices:[],noticesDismissed:!1,get mode(){return this.config?.mode??"open"},get openAccess(){return!!this.config?.openAccess},get isAuthenticated(){return!!this.session?.authenticated},get user(){return this.session?.user??null},get grants(){return this.session?.grants??{}},get username(){return this.user?.username??(this.openAccess?"system":null)},get rolesLabel(){const s=this.user?.roles;return Array.isArray(s)&&s.length?s.join(", "):""},can(s){if(this.openAccess)return!0;const t=this.user?.roles;return!!t&&e(t,s)},canForEnv(s,t){if(this.openAccess)return!0;if(this.can(t))return!0;const n=this.grants[s];return!(!Array.isArray(n)||0===n.length)&&e(n,t)},_grantsMatchAny(s){for(const t of Object.values(this.grants))if(Array.isArray(t))for(const n of s)if(e(t,n))return!0;return!1},canAny(s){return Array.isArray(s)&&s.some(s=>this.can(s))},canSection(s){if(this.openAccess)return!0;switch(s){case"db":return this.canAny(["data:read","schema:read","search:query"])||this._grantsMatchAny(["data:read","schema:read","search:query","data:*","schema:*","search:*","*"]);case"engines":case"system":return this.can("system:read");case"files":return this.can("files:read")||this._grantsMatchAny(["files:read","files:*","*"]);case"queue":return this.canAny(["queue:read","queue:work"])||this._grantsMatchAny(["queue:read","queue:work","queue:*","*"]);case"functions":return this.canAny(["functions:read","functions:run"])||this._grantsMatchAny(["functions:read","functions:run","functions:*","*"]);case"auth":return this.can("auth:read");case"sync":return this.can("sync:read");default:return!1}},permTooltip(s){return this.can(s)?"":`Requires ${s} permission`},get modeLabel(){return this.openAccess?"Open access":"secure"===this.mode?"Secure":String(this.mode||"auth")},get visibleNotices(){return this.noticesDismissed?[]:this.notices||[]},dismissNotices(){this.noticesDismissed=!0;try{sessionStorage.setItem("okdb_notices_dismissed","1")}catch{}},async loadConfig(){const s=await fetch("./login/config",{credentials:"same-origin"}),e=await s.json().catch(()=>({}));return this.config=e?.data||{},this.config},async loadSession(){if(this.openAccess)return this.session={authenticated:!0,user:{username:"system",roles:["admin"]},grants:{}},this.session;const s=await fetch("./session",{credentials:"same-origin"});if(!s.ok)return this.session={authenticated:!1,user:null,grants:{}},this.session;const e=await s.json().catch(()=>({})),t=e?.data||e?.result||{authenticated:!1,user:null};return this.session={grants:{},...t},this.session},async loadCatalog(){const s=await fetch("./api/auth/permissions",{credentials:"same-origin"});if(!s.ok)return null;const e=await s.json().catch(()=>({})),n=e?.data||e?.result||null;return n?.implies&&t(n.implies),this.catalog=n,n},async loadNotices(){try{if("1"===sessionStorage.getItem("okdb_notices_dismissed"))return void(this.noticesDismissed=!0);const s=await fetch("./api/notices",{credentials:"same-origin"});if(s.ok){const e=await s.json().catch(()=>({}));this.notices=e?.data?.notices??e?.result?.notices??[]}}catch{}},async init(){this.loading=!0,this.error=null;try{await this.loadConfig(),await this.loadSession(),await this.loadCatalog(),await this.loadNotices()}catch(s){throw this.error=s?.message||String(s),s}finally{this.loading=!1}},async logout(){await fetch("/auth/logout",{method:"POST",credentials:"same-origin",headers:{"content-type":"application/json"}}).catch(()=>{}),this.session={authenticated:!1,user:null};const s=encodeURIComponent("/admin/index.html");window.location.replace(`/admin/login?redirect=${s}`)}});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
import{ok as e}from"../modules/ok.js";const t=["system:ready","system:stopped","system:clock_change","system:poke","system:drain","system:bus_state_change","item:create","item:update","item:remove","index:reset","index:ready","index:progress","index:drop","index:registered","fts:registered","fts:drop","fts:reset","sync:apply","txn:start","txn:end","txn:rollback","type:registered","type:drop","env:opened","env:removed","engine:started","engine:stopped","engine:error","engine:installed","engine:uninstalled","embeddings:indexer:ready","embeddings:indexer:flushed","embeddings:indexer:doc:done","embeddings:indexer:doc:failed","embeddings:indexer:doc:queued","embeddings:doc:status_change","embeddings:pipeline:ready","queue:enqueued","queue:done","queue:failed","queue:retry","queue:removed","queue:reconciled","processor:ready","processor:progress","processor:error","processor:paused","processor:resumed","processor:retry","relay:error"];export{t as ALL_EVENTS};let n=null;const r={};function s(e){try{return JSON.parse(e)}catch{return null}}function o(e,t){const n=r[e];if(n)for(const e of n)try{e(t)}catch(e){console.error("events-store handler error",e)}}function i(e,t){return[...e.length>=500?e.slice(-499):e,t]}const d=e.proxy({connected:!1,connecting:!1,error:null,activity:[],get logs(){return this.activity.filter(e=>"log"===e._kind)},connect(e=null){if(n||this.connecting)return;this.connecting=!0,this.error=null;let r=__ENV__.API+"/events";e?.length&&(r+="?types="+encodeURIComponent(e.join(",")));const d=new EventSource(r);n=d,d.addEventListener("open",()=>{this.connected=!0,this.connecting=!1,this.error=null}),d.addEventListener("error",()=>{this.connected=!1,this.connecting=!1,this.error="Stream disconnected — reconnecting…"});const c=e=>{const t=s(e.data);if(!t)return;const n={_kind:"log",_ts:t._ts??t.ts??Date.now(),...t};this.activity=i(this.activity,n),o("log",t)};d.addEventListener("log",c);for(const e of t)d.addEventListener(e,t=>{try{const n=s(t.data);if(!n)return;const r={_kind:"event",_event:e,_ts:n._ts??Date.now(),...n};this.activity=i(this.activity,r),o(e,n)}catch{}});d.onmessage=c},disconnect(){n?.close(),n=null,this.connected=!1,this.connecting=!1},on:(e,t)=>(r[e]||(r[e]=new Set),r[e].add(t),()=>r[e]?.delete(t)),clearActivity(){this.activity=[]},clearLogs(){this.clearActivity()}});export default d;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const _0x59b7f0=_0x3260;(function(_0x16fb8b,_0xddc102){const _0x19b2b4=_0x3260,_0x35e740=_0x16fb8b();while(!![]){try{const _0x2ca665=parseInt(_0x19b2b4(0x10b))/0x1*(parseInt(_0x19b2b4(0x13e))/0x2)+parseInt(_0x19b2b4(0x12e))/0x3+parseInt(_0x19b2b4(0x120))/0x4+-parseInt(_0x19b2b4(0xe8))/0x5+parseInt(_0x19b2b4(0x14b))/0x6+-parseInt(_0x19b2b4(0x101))/0x7+-parseInt(_0x19b2b4(0xea))/0x8*(parseInt(_0x19b2b4(0xf1))/0x9);if(_0x2ca665===_0xddc102)break;else _0x35e740['push'](_0x35e740['shift']());}catch(_0x562b42){_0x35e740['push'](_0x35e740['shift']());}}}(_0x41c8,0xce38f));import{ok as _0x338a26}from'../modules/ok.js';import _0xbaeb74 from'./okdb-store.js';import _0x44b670 from'./events-store.js';function _0x41c8(){const _0x4fd748=['functionsBase','POST','setModalPayloadDraft','3342078UzWgYX','trim','overview','modalPayloadError','\x20\x20return\x20{\x20ok:\x20true\x20};','Payload\x20JSON\x20is\x20invalid','data','stringify','beginCreateDraft','modalNameDraft','logs','envName','level','import','loading','console','70chkZvF','payloadError','/runs/','now','modalRunning','loadList','modalDescriptionDraft','/functions','create','selectedName','items','modalUnsafeDraft','sourceDraft','6495420vpRcTL','Function\x20script\x20must\x20be\x20an\x20anonymous\x20arrow\x20function\x20of\x20the\x20form\x20[async]\x20(ctx)\x20=>\x20{}','join','modalSourceDraft','dryRunMode','modalPreviewRun','has','modalValidation','encode','detail','FUNCTION_SCRIPT_TOO_LARGE','getLogsForRun','FUNCTION_SCRIPT_REQUIRED','filter','find','finishedAt','code','modalMaterializerContextDraft','/env/','source','resetSelection','reloadList','edit','length','memoryMb','isFinite','worker_threads','sort','selected','return\x20(','select','loadRuns','\x20\x20//\x20ctx.env\x20\x20\x20\x20\x20—\x20env-scoped\x20facade:\x20put,\x20get,\x20query,\x20txn,\x20queue,\x20files,\x20...','Failed\x20to\x20save\x20function','/preview','runs','requestedAt','logsForRun','name','currentView','message','replace','timeoutMs','\x20\x20//\x20ctx.log\x20\x20\x20\x20\x20—\x20structured\x20logger:\x20ctx.log.info(msg,\x20data)','/runs','catch','_ts','7424845sGYTTT','modalAllowFetchDraft','8zvulxc','Function\x20script\x20failed\x20to\x20compile','Function\x20script\x20exceeds\x2065536\x20bytes','\x20\x20//\x20Tip:\x20use\x20the\x20\x22seed\x22\x20template\x20when\x20you\x20want\x20bulk\x20inserts\x20via\x20ctx.env.txn(...)','info','DELETE','\x20\x20//\x20ctx.payload\x20—\x20caller\x20input','17144154xSQjEw','meta','loadOverviewRuns','runId','modalJobContextDraft','{\x0a\x20\x20\x0a}','PUT','hydrateOverview','Function\x20script\x20source\x20is\x20required','latestRun','setModalSourceDraft','test','request','parsePayloadDraft','msg','execution','7179438UjgoXB','proxy','buildModalDefinition','hasEnv','Failed\x20to\x20run\x20function','map','selectedRun','live','setModalPreviewContext','overviewRuns','39747gKujWs','running','saving','isArray','FUNCTION_SCRIPT_INVALID_SHAPE','modalEnabledDraft','title','string','add','runtime','enabled','key','modalMode','value','modalProcessorContextDraft','payloadDraft','modalMemoryMbDraft','json','FUNCTION_SCRIPT_COMPILE_FAILED','/run','application/json','6689820Ffduzy','modalTimeoutMsDraft','modalPayloadDraft','slice','validateSource','error','parse','modalPreviewLogs','push','set','script'];_0x41c8=function(){return _0x4fd748;};return _0x41c8();}const a=['async\x20(ctx)\x20=>\x20{',_0x59b7f0(0xf0),_0x59b7f0(0xd9),_0x59b7f0(0xe4),_0x59b7f0(0xed),'',_0x59b7f0(0x132),'}'][_0x59b7f0(0xbb)]('\x0a'),r=_0x59b7f0(0xf6),i=[{'symbol':'require','pattern':/(^|[^\w$.])require\s*\(/},{'symbol':_0x59b7f0(0x13b),'pattern':/(^|[^\w$.])import\b/},{'symbol':_0x59b7f0(0x13d),'pattern':/(^|[^\w$.])console\b/},{'symbol':'module','pattern':/(^|[^\w$.])module\b/},{'symbol':'exports','pattern':/(^|[^\w$.])exports\b/},{'symbol':'process','pattern':/(^|[^\w$.])process\b/},{'symbol':'child_process','pattern':/child_process/},{'symbol':_0x59b7f0(0xd3),'pattern':/worker_threads/}];function _0x3260(_0x4445f9,_0x2ec482){_0x4445f9=_0x4445f9-0xba;const _0x41c8c2=_0x41c8();let _0x3260f2=_0x41c8c2[_0x4445f9];return _0x3260f2;}function n(_0x33f525){const _0x85f6f5=_0x59b7f0;return null==_0x33f525?_0x33f525:JSON[_0x85f6f5(0x126)](JSON[_0x85f6f5(0x135)](_0x33f525));}function o(_0xa1cb62={},_0x432e04='persisted'){const _0x1ab23b=_0x59b7f0,_0x72aa6c=_0xa1cb62?.['meta']??null,_0xe5bf82=_0xa1cb62?.['msg']??_0xa1cb62?.[_0x1ab23b(0xe1)]??_0xa1cb62?.['content']??_0xa1cb62?.[_0x1ab23b(0x111)]??'';return{'runId':_0xa1cb62?.[_0x1ab23b(0xf4)]??_0x72aa6c?.[_0x1ab23b(0xf4)]??null,'ts':_0xa1cb62?.['ts']??_0xa1cb62?.[_0x1ab23b(0xe7)]??Date[_0x1ab23b(0x141)](),'level':_0xa1cb62?.[_0x1ab23b(0x13a)]??_0x1ab23b(0xee),'msg':'string'==typeof _0xe5bf82?_0xe5bf82:JSON[_0x1ab23b(0x135)](_0xe5bf82??''),'meta':_0x72aa6c,'source':_0x432e04};}export default _0x338a26[_0x59b7f0(0x102)]({'items':[],'selectedName':null,'selected':null,'runs':[],'overviewRuns':[],'selectedRun':null,'sourceDraft':'','payloadDraft':r,'currentView':_0x59b7f0(0x130),'modalMode':_0x59b7f0(0x146),'modalNameDraft':'','modalSourceDraft':a,'modalPayloadDraft':r,'modalJobContextDraft':null,'modalProcessorContextDraft':null,'modalMaterializerContextDraft':null,'modalDescriptionDraft':'','modalEnabledDraft':!0x0,'modalUnsafeDraft':!0x1,'modalTimeoutMsDraft':null,'modalMemoryMbDraft':null,'modalAllowFetchDraft':!0x0,'modalValidation':{'ok':!0x1,'code':'FUNCTION_SCRIPT_REQUIRED','message':_0x59b7f0(0xf9)},'modalPayloadError':null,'modalPreviewRun':null,'modalPreviewLogs':[],'modalRunning':!0x1,'modalDryRunMode':!0x1,'loading':!0x1,'saving':!0x1,'running':!0x1,'dryRunMode':!0x1,'payloadError':null,'error':null,get 'envName'(){return _0xbaeb74['selectedEnv']||null;},get 'isGlobalScope'(){const _0x1d7dbf=_0x59b7f0;return'~system'===this[_0x1d7dbf(0x139)];},get 'hasEnv'(){const _0x2048c8=_0x59b7f0;return!!this[_0x2048c8(0x139)];},get 'functionsBase'(){const _0x5c1ea=_0x59b7f0;return this['envName']?__ENV__['API']+_0x5c1ea(0xcb)+encodeURIComponent(this[_0x5c1ea(0x139)])+_0x5c1ea(0x145):null;},get 'canOpenModal'(){return!!this['functionsBase'];},get 'hasSelected'(){const _0x128e45=_0x59b7f0;return!!this[_0x128e45(0x147)]&&!!this[_0x128e45(0xd5)];},get 'latestRun'(){const _0x24dd9c=_0x59b7f0;return this[_0x24dd9c(0xdc)]?.[0x0]?.[_0x24dd9c(0x118)]||this[_0x24dd9c(0xdc)]?.[0x0]||null;},get 'activeRun'(){return this['selectedRun']||this['latestRun']||null;},get 'functionsOverview'(){const _0xa80b98=_0x59b7f0,_0x53c661=new Map();for(const _0x39bf56 of this[_0xa80b98(0x10a)]||[]){const _0x482b60=_0x39bf56?.['value']||_0x39bf56,_0x51e457=_0x482b60?.['functionName'];_0x51e457&&!_0x53c661[_0xa80b98(0xbf)](_0x51e457)&&_0x53c661[_0xa80b98(0x129)](_0x51e457,_0x482b60);}return(this[_0xa80b98(0x148)]||[])[_0xa80b98(0x106)](_0x50ffea=>({..._0x50ffea,'latestRun':_0x53c661['get'](_0x50ffea?.[_0xa80b98(0x116)])||null}));},get 'selectedFunctionTitle'(){const _0x7a6881=_0x59b7f0;return this['selected']?.[_0x7a6881(0xdf)]||this['selectedName']||null;},get 'selectedLogEntries'(){const _0x43bd95=_0x59b7f0,_0x38a46f=this['selectedRun']?.['id']||this[_0x43bd95(0x107)]?.['runId'];if(_0x38a46f)return this[_0x43bd95(0xde)](_0x38a46f);const _0x14e9d8=this[_0x43bd95(0xfa)]?.['id']||this['latestRun']?.['runId'];return _0x14e9d8?this[_0x43bd95(0xde)](_0x14e9d8):[];},'logsForRun'(_0x57b743){const _0x1f3b36=_0x59b7f0;if(!_0x57b743)return[];const _0x1ee132=[this['selectedRun'],this['latestRun'],...(this[_0x1f3b36(0xdc)]||[])[_0x1f3b36(0x106)](_0x3b79c7=>_0x3b79c7?.[_0x1f3b36(0x118)]||_0x3b79c7)]['find'](_0x27bf25=>(_0x27bf25?.['id']||_0x27bf25?.[_0x1f3b36(0xf4)])===_0x57b743)?.['logs'],_0x1d1323=[...Array[_0x1f3b36(0x10e)](_0x1ee132)?_0x1ee132[_0x1f3b36(0x106)](_0x4847d2=>o(_0x4847d2,'persisted')):[],...(_0x44b670['logs']||[])[_0x1f3b36(0xc6)](_0x3e905c=>(_0x3e905c?.[_0x1f3b36(0xf4)]||_0x3e905c?.[_0x1f3b36(0xf2)]?.[_0x1f3b36(0xf4)])===_0x57b743)[_0x1f3b36(0x106)](_0x3d1600=>o(_0x3d1600,_0x1f3b36(0x108)))],_0x1a7c85=new Set(),_0x11a92f=[];for(const _0x34d004 of _0x1d1323){const _0x4147d6=_0x34d004[_0x1f3b36(0xf4)]+'|'+_0x34d004['ts']+'|'+_0x34d004[_0x1f3b36(0x13a)]+'|'+_0x34d004[_0x1f3b36(0xff)]+'|'+JSON[_0x1f3b36(0x135)](_0x34d004['meta']??null);_0x1a7c85[_0x1f3b36(0xbf)](_0x4147d6)||(_0x1a7c85[_0x1f3b36(0x113)](_0x4147d6),_0x11a92f[_0x1f3b36(0x128)](_0x34d004));}return _0x11a92f['sort']((_0xbdf427,_0x51cdcd)=>(_0xbdf427['ts']??0x0)-(_0x51cdcd['ts']??0x0)),_0x11a92f;},'resetSelection'(){const _0x5848bc=_0x59b7f0;this[_0x5848bc(0x147)]=null,this[_0x5848bc(0xd5)]=null,this[_0x5848bc(0xdc)]=[],this[_0x5848bc(0x10a)]=[],this[_0x5848bc(0x107)]=null,this['sourceDraft']='',this[_0x5848bc(0x11a)]=r,this[_0x5848bc(0x13f)]=null,this['error']=null;},'validateSource'(_0x33f7ed){const _0xf78cf0=_0x59b7f0,_0x5defdf=_0xf78cf0(0x112)==typeof _0x33f7ed?_0x33f7ed[_0xf78cf0(0xe2)](/\r\n/g,'\x0a')[_0xf78cf0(0x12f)]():'';if(!_0x5defdf)return{'ok':!0x1,'code':_0xf78cf0(0xc5),'message':_0xf78cf0(0xf9)};const _0x38c916=new TextEncoder()[_0xf78cf0(0xc1)](_0x5defdf)[_0xf78cf0(0xd0)];if(_0x38c916>0x10000)return{'ok':!0x1,'code':_0xf78cf0(0xc3),'message':_0xf78cf0(0xec)};if(!/^(async\s+)?\(\s*[A-Za-z_$][\w$]*\s*\)\s*=>/[_0xf78cf0(0xfc)](_0x5defdf))return{'ok':!0x1,'code':_0xf78cf0(0x10f),'message':_0xf78cf0(0xba)};for(const {symbol:_0x26988e,pattern:_0x2fea01}of i)if(_0x2fea01[_0xf78cf0(0xfc)](_0x5defdf))return{'ok':!0x1,'code':'FUNCTION_SCRIPT_FORBIDDEN_SYMBOL','message':'Function\x20script\x20may\x20not\x20reference\x20'+_0x26988e};try{new Function(_0xf78cf0(0xd6)+_0x5defdf+');')();}catch(_0x2e45e9){return{'ok':!0x1,'code':_0xf78cf0(0x11d),'message':_0x2e45e9?.['message']||_0xf78cf0(0xeb)};}return{'ok':!0x0,'code':null,'message':'','normalizedSource':_0x5defdf,'bytes':_0x38c916};},'parsePayloadDraft'(_0x241404=this[_0x59b7f0(0x11a)]){const _0x3a25e9=_0x59b7f0,_0x5f6bae=String(_0x241404??'')[_0x3a25e9(0x12f)]();return _0x5f6bae?JSON[_0x3a25e9(0x126)](_0x5f6bae):null;},'setModalSourceDraft'(_0x4f2386){const _0x1e5382=_0x59b7f0;this[_0x1e5382(0xbc)]=_0x4f2386??'',this[_0x1e5382(0xc0)]=this[_0x1e5382(0x124)](this[_0x1e5382(0xbc)]);},'setModalPayloadDraft'(_0x147747){const _0xcf0472=_0x59b7f0;this[_0xcf0472(0x122)]=_0x147747??r;try{this[_0xcf0472(0xfe)](this[_0xcf0472(0x122)]),this[_0xcf0472(0x131)]=null;}catch(_0x38696c){this[_0xcf0472(0x131)]=_0x38696c?.[_0xcf0472(0xe1)]||'Payload\x20JSON\x20is\x20invalid';}},'setModalPreviewContext'({jobContext:_0x319dfa=null,processorContext:_0x529483=null,materializerContext:_0x37f1d4=null}={}){const _0x39bd2e=_0x59b7f0;this[_0x39bd2e(0xf5)]=n(_0x319dfa),this[_0x39bd2e(0x119)]=n(_0x529483),this[_0x39bd2e(0xca)]=n(_0x37f1d4);},'beginCreateDraft'(){const _0x4ce683=_0x59b7f0;this[_0x4ce683(0x117)]=_0x4ce683(0x146),this['modalNameDraft']='',this[_0x4ce683(0x144)]='',this[_0x4ce683(0x110)]=!0x0,this['modalUnsafeDraft']=!0x1,this[_0x4ce683(0x121)]=null,this['modalMemoryMbDraft']=null,this['modalAllowFetchDraft']=!0x0,this[_0x4ce683(0xbe)]=null,this[_0x4ce683(0x127)]=[],this[_0x4ce683(0x109)]({}),this[_0x4ce683(0x12d)](this[_0x4ce683(0x11a)]||r),this[_0x4ce683(0xfb)](a);},'beginEditDraft'(){const _0x307111=_0x59b7f0,_0x41734d=this['selected'];this[_0x307111(0x117)]=_0x307111(0xcf),this[_0x307111(0x137)]=_0x41734d?.[_0x307111(0xdf)]||this['selectedName']||'',this['modalDescriptionDraft']=_0x41734d?.['metadata']?.['description']||'',this[_0x307111(0x110)]=!0x1!==_0x41734d?.[_0x307111(0x115)],this[_0x307111(0x149)]=!0x0===_0x41734d?.['unsafe'],this[_0x307111(0x121)]=_0x41734d?.[_0x307111(0x114)]?.[_0x307111(0xe3)]??null,this['modalMemoryMbDraft']=_0x41734d?.[_0x307111(0x114)]?.[_0x307111(0xd1)]??null,this[_0x307111(0xe9)]=!0x1!==_0x41734d?.['runtime']?.['allowFetch'],this[_0x307111(0xbe)]=null,this['modalPreviewLogs']=[],this[_0x307111(0x109)]({}),this[_0x307111(0x12d)](this[_0x307111(0x11a)]||r),this[_0x307111(0xfb)](_0x41734d?.[_0x307111(0x12a)]?.['source']||this[_0x307111(0x14a)]||a);},'buildModalDefinition'(){const _0x1d2eac=_0x59b7f0,_0x5282ca={};return Number[_0x1d2eac(0xd2)](this[_0x1d2eac(0x121)])&&this[_0x1d2eac(0x121)]>0x0&&(_0x5282ca[_0x1d2eac(0xe3)]=this[_0x1d2eac(0x121)]),Number['isFinite'](this['modalMemoryMbDraft'])&&this[_0x1d2eac(0x11b)]>0x0&&(_0x5282ca['memoryMb']=this['modalMemoryMbDraft']),_0x5282ca['allowFetch']=!0x1!==this[_0x1d2eac(0xe9)],{'name':String(this[_0x1d2eac(0x137)]||'')[_0x1d2eac(0x12f)](),'source':this[_0x1d2eac(0xc0)]?.['normalizedSource']||String(this[_0x1d2eac(0xbc)]||'')[_0x1d2eac(0x12f)](),'metadata':{'description':String(this['modalDescriptionDraft']||'')[_0x1d2eac(0x12f)]()},'enabled':!0x1!==this['modalEnabledDraft'],'unsafe':!0x0===this[_0x1d2eac(0x149)],'runtime':_0x5282ca};},get 'canSaveModal'(){const _0x43da0d=_0x59b7f0;return!(!String(this[_0x43da0d(0x137)]||'')[_0x43da0d(0x12f)]()||!this[_0x43da0d(0xc0)]?.['ok']||this[_0x43da0d(0x131)]||this[_0x43da0d(0x10d)]);},async 'loadList'(){const _0x2fceca=_0x59b7f0;if(!this['functionsBase'])return[];this[_0x2fceca(0x13c)]=!0x0,this['error']=null;try{const _0x700b33=await fetch(this[_0x2fceca(0x12b)]),_0x59d330=await _0x700b33[_0x2fceca(0x11c)]();return this[_0x2fceca(0x148)]=_0x59d330?.[_0x2fceca(0x134)]||[],this['selectedName']&&(this[_0x2fceca(0x148)]['find'](_0x24f3d7=>_0x24f3d7['key']===this[_0x2fceca(0x147)])||this[_0x2fceca(0xcd)]()),this[_0x2fceca(0x148)];}catch(_0x2a28c4){throw this[_0x2fceca(0x125)]=_0x2a28c4?.[_0x2fceca(0xe1)]||'Failed\x20to\x20load\x20functions',_0x2a28c4;}finally{this[_0x2fceca(0x13c)]=!0x1;}},async 'reloadList'(){const _0x501696=_0x59b7f0;return this[_0x501696(0x148)]=[],this[_0x501696(0x143)]();},'setView'(_0x17c4d9='overview'){const _0x398e67=_0x59b7f0;this[_0x398e67(0xe0)]='detail'===_0x17c4d9?_0x398e67(0xc2):_0x398e67(0x130);},async 'loadOverviewRuns'(_0x1208eb=0x18){const _0x38829c=_0x59b7f0;if(!this[_0x38829c(0x12b)])return[];const _0x3185cd=(this[_0x38829c(0x148)]||[])[_0x38829c(0x106)](_0x531e9f=>_0x531e9f?.[_0x38829c(0x116)])['filter'](Boolean),_0x2b1adf=[];for(const _0x140c04 of _0x3185cd){const _0x1d1c37=await fetch(this[_0x38829c(0x12b)]+'/'+encodeURIComponent(_0x140c04)+_0x38829c(0xe5)),_0x2e8ff4=await _0x1d1c37['json'](),_0x2a2655=(_0x2e8ff4?.['data']||[])[_0x38829c(0x106)](_0x30bef7=>_0x30bef7?.[_0x38829c(0x118)]?_0x30bef7:{'key':_0x30bef7?.['id']||_0x30bef7?.[_0x38829c(0xf4)],'value':_0x30bef7});_0x2b1adf[_0x38829c(0x128)](..._0x2a2655);}return _0x2b1adf[_0x38829c(0xd4)]((_0xfed26,_0x47dc89)=>{const _0x1fe66c=_0x38829c,_0x7a3faf=_0xfed26?.['value']?.[_0x1fe66c(0x100)]?.['finishedAt']??_0xfed26?.[_0x1fe66c(0x118)]?.[_0x1fe66c(0xfd)]?.[_0x1fe66c(0xdd)]??0x0;return(_0x47dc89?.['value']?.[_0x1fe66c(0x100)]?.[_0x1fe66c(0xc8)]??_0x47dc89?.[_0x1fe66c(0x118)]?.[_0x1fe66c(0xfd)]?.[_0x1fe66c(0xdd)]??0x0)-_0x7a3faf;}),this[_0x38829c(0x10a)]=_0x2b1adf[_0x38829c(0x123)](0x0,_0x1208eb),this[_0x38829c(0x10a)];},async 'hydrateOverview'(){const _0x41ae5d=_0x59b7f0;await this[_0x41ae5d(0x143)](),await this[_0x41ae5d(0xf3)]();},async 'select'(_0x4ac3e1){const _0x48adfc=_0x59b7f0;if(this[_0x48adfc(0x147)]=_0x4ac3e1||null,this[_0x48adfc(0x107)]=null,this[_0x48adfc(0xe0)]=_0x4ac3e1?_0x48adfc(0xc2):'overview',!_0x4ac3e1)return this[_0x48adfc(0xd5)]=null,this[_0x48adfc(0x14a)]='',this['runs']=[],null;const _0x5e33e0=await fetch(this[_0x48adfc(0x12b)]+'/'+encodeURIComponent(_0x4ac3e1)),_0x25ae78=await _0x5e33e0[_0x48adfc(0x11c)]();if(this[_0x48adfc(0xd5)]=_0x25ae78?.[_0x48adfc(0x134)]||null,this['sourceDraft']=this[_0x48adfc(0xd5)]?.[_0x48adfc(0x12a)]?.[_0x48adfc(0xcc)]||'',this[_0x48adfc(0x13f)]=null,await this[_0x48adfc(0xd8)](_0x4ac3e1),!this[_0x48adfc(0x107)]&&this[_0x48adfc(0xdc)]?.[_0x48adfc(0xd0)]){const _0x1da36a=this['runs'][0x0];this['selectedRun']=_0x1da36a?.[_0x48adfc(0x118)]||_0x1da36a||null;}return this[_0x48adfc(0xd5)];},async 'loadRuns'(_0x53fa1c=this[_0x59b7f0(0x147)]){const _0x485d1c=_0x59b7f0;if(!_0x53fa1c)return this[_0x485d1c(0xdc)]=[],[];const _0x24736f=await fetch(this[_0x485d1c(0x12b)]+'/'+encodeURIComponent(_0x53fa1c)+'/runs'),_0x3e8499=await _0x24736f[_0x485d1c(0x11c)]();if(this[_0x485d1c(0xdc)]=_0x3e8499?.[_0x485d1c(0x134)]||[],this[_0x485d1c(0x107)]){const _0x2d3fe9=this[_0x485d1c(0x107)]?.['id']||this[_0x485d1c(0x107)]?.[_0x485d1c(0xf4)],_0x23089c=this['runs'][_0x485d1c(0x106)](_0x19a3c1=>_0x19a3c1?.[_0x485d1c(0x118)]||_0x19a3c1)[_0x485d1c(0xc7)](_0x211d52=>(_0x211d52?.['id']||_0x211d52?.[_0x485d1c(0xf4)])===_0x2d3fe9);this['selectedRun']=_0x23089c||null;}return this['runs'];},async 'refreshSelected'(){const _0x65a9ec=_0x59b7f0;if(!this['selectedName'])return null;const _0x47e21a=this['selectedRun']?.['id']||this['selectedRun']?.[_0x65a9ec(0xf4)];if(await this[_0x65a9ec(0xd7)](this[_0x65a9ec(0x147)]),_0x47e21a){const _0x91b72d=this['runs'][_0x65a9ec(0x106)](_0x2d71b5=>_0x2d71b5?.['value']||_0x2d71b5)[_0x65a9ec(0xc7)](_0x134489=>(_0x134489?.['id']||_0x134489?.[_0x65a9ec(0xf4)])===_0x47e21a);this[_0x65a9ec(0x107)]=_0x91b72d||this[_0x65a9ec(0x107)];}return await this['loadOverviewRuns'](),this[_0x65a9ec(0xd5)];},'setSourceDraft'(_0x53c97d){const _0x24c64c=_0x59b7f0;this[_0x24c64c(0x14a)]=_0x53c97d??'';},'setPayloadDraft'(_0x55cfd6){const _0x564947=_0x59b7f0;this[_0x564947(0x11a)]=_0x55cfd6??r;try{this['parsePayloadDraft'](this[_0x564947(0x11a)]),this[_0x564947(0x13f)]=null;}catch(_0x9bee41){this[_0x564947(0x13f)]=_0x9bee41?.[_0x564947(0xe1)]||_0x564947(0x133);}},async 'create'(_0x29cf47={}){const _0x399570=_0x59b7f0;this[_0x399570(0x10d)]=!0x0,this[_0x399570(0x125)]=null;try{const _0x48f978={..._0x29cf47},_0x832d01=await fetch(this[_0x399570(0x12b)],{'method':_0x399570(0x12c),'headers':{'content-type':'application/json'},'body':JSON[_0x399570(0x135)](_0x48f978)}),_0x6ada89=await _0x832d01[_0x399570(0x11c)]();if(!_0x832d01['ok'])throw new Error(_0x6ada89?.[_0x399570(0x125)]?.['message']||_0x6ada89?.[_0x399570(0x134)]?.['error']||'Failed\x20to\x20create\x20function');return await this[_0x399570(0xce)](),await this['select'](_0x6ada89?.[_0x399570(0x134)]?.[_0x399570(0xdf)]||_0x29cf47['name']),_0x6ada89?.[_0x399570(0x134)];}finally{this[_0x399570(0x10d)]=!0x1;}},async 'saveSelected'(_0x405189={}){const _0x1faf69=_0x59b7f0;if(!this[_0x1faf69(0x147)])return null;this[_0x1faf69(0x10d)]=!0x0,this[_0x1faf69(0x125)]=null;try{const _0x26d65f={..._0x405189,'source':_0x405189?.[_0x1faf69(0xcc)]??this[_0x1faf69(0x14a)]},_0xe233af=await fetch(this[_0x1faf69(0x12b)]+'/'+encodeURIComponent(this[_0x1faf69(0x147)]),{'method':_0x1faf69(0xf7),'headers':{'content-type':'application/json'},'body':JSON[_0x1faf69(0x135)](_0x26d65f)}),_0xacf1ee=await _0xe233af[_0x1faf69(0x11c)]();if(!_0xe233af['ok'])throw new Error(_0xacf1ee?.['error']?.['message']||_0xacf1ee?.['data']?.[_0x1faf69(0x125)]||_0x1faf69(0xda));return await this['reloadList'](),await this[_0x1faf69(0xd7)](this[_0x1faf69(0x147)]),_0xacf1ee?.[_0x1faf69(0x134)];}finally{this['saving']=!0x1;}},async 'saveModalDefinition'(){const _0x487367=_0x59b7f0,_0x141e17=this[_0x487367(0x103)]();return _0x487367(0xcf)===this[_0x487367(0x117)]&&this['selectedName']?await this['saveSelected'](_0x141e17):this[_0x487367(0x146)](_0x141e17);},async 'remove'(_0x271b10=this[_0x59b7f0(0x147)]){const _0x5236e7=_0x59b7f0;if(!_0x271b10)return!0x1;this[_0x5236e7(0x10d)]=!0x0,this[_0x5236e7(0x125)]=null;try{const _0x45a8d4=await fetch(this[_0x5236e7(0x12b)]+'/'+encodeURIComponent(_0x271b10),{'method':_0x5236e7(0xef)});if(!_0x45a8d4['ok']&&0xcc!==_0x45a8d4['status']){const _0x11e6f0=await _0x45a8d4[_0x5236e7(0x11c)]()[_0x5236e7(0xe6)](()=>({}));throw new Error(_0x11e6f0?.[_0x5236e7(0x125)]?.[_0x5236e7(0xe1)]||_0x11e6f0?.['data']?.[_0x5236e7(0x125)]||'Failed\x20to\x20delete\x20function');}return await this[_0x5236e7(0xce)](),await this['loadOverviewRuns'](),this['selectedName']===_0x271b10&&this['resetSelection'](),!0x0;}finally{this['saving']=!0x1;}},async 'runSelected'(){const _0x15d4cd=_0x59b7f0;if(!this[_0x15d4cd(0x147)])return null;this[_0x15d4cd(0x10c)]=!0x0,this[_0x15d4cd(0x125)]=null;try{let _0x26e9de=null;try{_0x26e9de=this[_0x15d4cd(0xfe)](this[_0x15d4cd(0x11a)]),this['payloadError']=null;}catch(_0x1763b4){throw this[_0x15d4cd(0x13f)]=_0x1763b4?.['message']||'Payload\x20JSON\x20is\x20invalid',_0x1763b4;}const _0x2bb02a=await fetch(this['functionsBase']+'/'+encodeURIComponent(this[_0x15d4cd(0x147)])+_0x15d4cd(0x11e),{'method':_0x15d4cd(0x12c),'headers':{'content-type':_0x15d4cd(0x11f)},'body':JSON[_0x15d4cd(0x135)]({'payload':_0x26e9de,...this['dryRunMode']&&{'dryRun':!0x0}})}),_0x3f9622=await _0x2bb02a[_0x15d4cd(0x11c)]();if(!_0x2bb02a['ok']){const _0x5a9a2d=new Error(_0x3f9622?.[_0x15d4cd(0x125)]?.[_0x15d4cd(0xe1)]||_0x3f9622?.[_0x15d4cd(0x134)]?.[_0x15d4cd(0x125)]||_0x15d4cd(0x105));throw _0x5a9a2d[_0x15d4cd(0xc9)]=_0x3f9622?.[_0x15d4cd(0x125)]?.['code']||null,_0x5a9a2d;}return await this[_0x15d4cd(0xd8)](this[_0x15d4cd(0x147)]),this[_0x15d4cd(0x107)]=n(_0x3f9622?.[_0x15d4cd(0x134)]||null),this[_0x15d4cd(0xbd)]||!this[_0x15d4cd(0x107)]?.['id']&&!this[_0x15d4cd(0x107)]?.[_0x15d4cd(0xf4)]||await this['selectRun'](this[_0x15d4cd(0x107)]['id']||this['selectedRun'][_0x15d4cd(0xf4)]),await this[_0x15d4cd(0xf3)](),this[_0x15d4cd(0x107)];}catch(_0x46579c){throw this[_0x15d4cd(0x125)]=_0x46579c?.['code']?_0x46579c[_0x15d4cd(0xc9)]+':\x20'+_0x46579c[_0x15d4cd(0xe1)]:_0x46579c?.[_0x15d4cd(0xe1)]||'Failed\x20to\x20run\x20function',_0x46579c;}finally{this['running']=!0x1;}},async 'runModalDraft'(){const _0x40f551=_0x59b7f0,_0x455f51=this['buildModalDefinition']();this['modalRunning']=!0x0,this[_0x40f551(0x125)]=null;try{const _0x3bd21a=this[_0x40f551(0xfe)](this[_0x40f551(0x122)]);this[_0x40f551(0x131)]=null,this[_0x40f551(0xbe)]=null,this[_0x40f551(0x127)]=[];const _0xee106d=await fetch(this[_0x40f551(0x12b)]+_0x40f551(0xdb),{'method':'POST','headers':{'content-type':_0x40f551(0x11f)},'body':JSON[_0x40f551(0x135)]({..._0x455f51,'payload':_0x3bd21a,...this['modalDryRunMode']&&{'dryRun':!0x0},...this[_0x40f551(0xf5)]?{'jobContext':n(this[_0x40f551(0xf5)])}:{},...this[_0x40f551(0x119)]?{'processorContext':n(this[_0x40f551(0x119)])}:{},...this[_0x40f551(0xca)]?{'materializerContext':n(this[_0x40f551(0xca)])}:{}})}),_0x17d951=await _0xee106d[_0x40f551(0x11c)]();if(!_0xee106d['ok'])throw new Error(_0x17d951?.[_0x40f551(0x125)]?.[_0x40f551(0xe1)]||_0x17d951?.[_0x40f551(0x134)]?.[_0x40f551(0x125)]||'Failed\x20to\x20run\x20draft');return this[_0x40f551(0xbe)]=n(_0x17d951?.['data']||null),this[_0x40f551(0x127)]=this['getLogsForRun'](this[_0x40f551(0xbe)]?.['id']||this['modalPreviewRun']?.[_0x40f551(0xf4)]),this[_0x40f551(0xbe)];}catch(_0x26d25e){throw _0x26d25e instanceof SyntaxError&&(this[_0x40f551(0x131)]=_0x26d25e?.[_0x40f551(0xe1)]||'Payload\x20JSON\x20is\x20invalid'),_0x26d25e;}finally{this[_0x40f551(0x142)]=!0x1;}},'getLogsForRun':_0x23fb71=>_0x23fb71?(_0x44b670[_0x59b7f0(0x138)]||[])['filter'](_0x472f57=>(_0x472f57?.[_0x59b7f0(0xf4)]||_0x472f57?.[_0x59b7f0(0xf2)]?.['runId'])===_0x23fb71):[],'refreshModalPreviewLogs'(){const _0x20d4b1=_0x59b7f0,_0x456a6d=this[_0x20d4b1(0xbe)]?.['id']||this[_0x20d4b1(0xbe)]?.[_0x20d4b1(0xf4)];return _0x456a6d?(this['modalPreviewLogs']=this[_0x20d4b1(0xc4)](_0x456a6d),this[_0x20d4b1(0x127)]):(this[_0x20d4b1(0x127)]=[],[]);},async 'selectRun'(_0x22ebe1){const _0x583b58=_0x59b7f0;if(!this[_0x583b58(0x147)]||!_0x22ebe1)return this[_0x583b58(0x107)]=null,null;const _0x52ce3c=await fetch(this['functionsBase']+'/'+encodeURIComponent(this[_0x583b58(0x147)])+_0x583b58(0x140)+encodeURIComponent(_0x22ebe1)),_0x53b2b3=await _0x52ce3c[_0x583b58(0x11c)]();return this['selectedRun']=_0x53b2b3?.[_0x583b58(0x134)]||null,this[_0x583b58(0x107)];},async 'onEnvChanged'(){const _0x33fefe=_0x59b7f0;this[_0x33fefe(0xcd)](),this[_0x33fefe(0x136)](),this['currentView']=_0x33fefe(0x130),this[_0x33fefe(0x104)]&&await this[_0x33fefe(0xf8)]();}});
|
|
1
|
+
import{ok as t}from"../modules/ok.js";import e from"./okdb-store.js";import s from"./events-store.js";const a=["async (ctx) => {"," // ctx.payload — caller input"," // ctx.env — env-scoped facade: put, get, query, txn, queue, files, ..."," // ctx.log — structured logger: ctx.log.info(msg, data)",' // Tip: use the "seed" template when you want bulk inserts via ctx.env.txn(...)',""," return { ok: true };","}"].join("\n"),r="{\n \n}",i=[{symbol:"require",pattern:/(^|[^\w$.])require\s*\(/},{symbol:"import",pattern:/(^|[^\w$.])import\b/},{symbol:"console",pattern:/(^|[^\w$.])console\b/},{symbol:"module",pattern:/(^|[^\w$.])module\b/},{symbol:"exports",pattern:/(^|[^\w$.])exports\b/},{symbol:"process",pattern:/(^|[^\w$.])process\b/},{symbol:"child_process",pattern:/child_process/},{symbol:"worker_threads",pattern:/worker_threads/}];function n(t){return null==t?t:JSON.parse(JSON.stringify(t))}function o(t={},e="persisted"){const s=t?.meta??null,a=t?.msg??t?.message??t?.content??t?.title??"";return{runId:t?.runId??s?.runId??null,ts:t?.ts??t?._ts??Date.now(),level:t?.level??"info",msg:"string"==typeof a?a:JSON.stringify(a??""),meta:s,source:e}}export default t.proxy({items:[],selectedName:null,selected:null,runs:[],overviewRuns:[],selectedRun:null,sourceDraft:"",payloadDraft:r,currentView:"overview",modalMode:"create",modalNameDraft:"",modalSourceDraft:a,modalPayloadDraft:r,modalJobContextDraft:null,modalProcessorContextDraft:null,modalMaterializerContextDraft:null,modalDescriptionDraft:"",modalEnabledDraft:!0,modalUnsafeDraft:!1,modalTimeoutMsDraft:null,modalMemoryMbDraft:null,modalAllowFetchDraft:!0,modalValidation:{ok:!1,code:"FUNCTION_SCRIPT_REQUIRED",message:"Function script source is required"},modalPayloadError:null,modalPreviewRun:null,modalPreviewLogs:[],modalRunning:!1,modalDryRunMode:!1,loading:!1,saving:!1,running:!1,dryRunMode:!1,payloadError:null,error:null,get envName(){return e.selectedEnv||null},get isGlobalScope(){return"~system"===this.envName},get hasEnv(){return!!this.envName},get functionsBase(){return this.envName?`${__ENV__.API}/env/${encodeURIComponent(this.envName)}/functions`:null},get canOpenModal(){return!!this.functionsBase},get hasSelected(){return!!this.selectedName&&!!this.selected},get latestRun(){return this.runs?.[0]?.value||this.runs?.[0]||null},get activeRun(){return this.selectedRun||this.latestRun||null},get functionsOverview(){const t=new Map;for(const e of this.overviewRuns||[]){const s=e?.value||e,a=s?.functionName;a&&!t.has(a)&&t.set(a,s)}return(this.items||[]).map(e=>({...e,latestRun:t.get(e?.key)||null}))},get selectedFunctionTitle(){return this.selected?.name||this.selectedName||null},get selectedLogEntries(){const t=this.selectedRun?.id||this.selectedRun?.runId;if(t)return this.logsForRun(t);const e=this.latestRun?.id||this.latestRun?.runId;return e?this.logsForRun(e):[]},logsForRun(t){if(!t)return[];const e=[this.selectedRun,this.latestRun,...(this.runs||[]).map(t=>t?.value||t)].find(e=>(e?.id||e?.runId)===t)?.logs,a=[...Array.isArray(e)?e.map(t=>o(t,"persisted")):[],...(s.logs||[]).filter(e=>(e?.runId||e?.meta?.runId)===t).map(t=>o(t,"live"))],r=new Set,i=[];for(const t of a){const e=`${t.runId}|${t.ts}|${t.level}|${t.msg}|${JSON.stringify(t.meta??null)}`;r.has(e)||(r.add(e),i.push(t))}return i.sort((t,e)=>(t.ts??0)-(e.ts??0)),i},resetSelection(){this.selectedName=null,this.selected=null,this.runs=[],this.overviewRuns=[],this.selectedRun=null,this.sourceDraft="",this.payloadDraft=r,this.payloadError=null,this.error=null},validateSource(t){const e="string"==typeof t?t.replace(/\r\n/g,"\n").trim():"";if(!e)return{ok:!1,code:"FUNCTION_SCRIPT_REQUIRED",message:"Function script source is required"};const s=(new TextEncoder).encode(e).length;if(s>65536)return{ok:!1,code:"FUNCTION_SCRIPT_TOO_LARGE",message:"Function script exceeds 65536 bytes"};if(!/^(async\s+)?\(\s*[A-Za-z_$][\w$]*\s*\)\s*=>/.test(e))return{ok:!1,code:"FUNCTION_SCRIPT_INVALID_SHAPE",message:"Function script must be an anonymous arrow function of the form [async] (ctx) => {}"};for(const{symbol:t,pattern:s}of i)if(s.test(e))return{ok:!1,code:"FUNCTION_SCRIPT_FORBIDDEN_SYMBOL",message:`Function script may not reference ${t}`};try{new Function(`return (${e});`)()}catch(t){return{ok:!1,code:"FUNCTION_SCRIPT_COMPILE_FAILED",message:t?.message||"Function script failed to compile"}}return{ok:!0,code:null,message:"",normalizedSource:e,bytes:s}},parsePayloadDraft(t=this.payloadDraft){const e=String(t??"").trim();return e?JSON.parse(e):null},setModalSourceDraft(t){this.modalSourceDraft=t??"",this.modalValidation=this.validateSource(this.modalSourceDraft)},setModalPayloadDraft(t){this.modalPayloadDraft=t??r;try{this.parsePayloadDraft(this.modalPayloadDraft),this.modalPayloadError=null}catch(t){this.modalPayloadError=t?.message||"Payload JSON is invalid"}},setModalPreviewContext({jobContext:t=null,processorContext:e=null,materializerContext:s=null}={}){this.modalJobContextDraft=n(t),this.modalProcessorContextDraft=n(e),this.modalMaterializerContextDraft=n(s)},beginCreateDraft(){this.modalMode="create",this.modalNameDraft="",this.modalDescriptionDraft="",this.modalEnabledDraft=!0,this.modalUnsafeDraft=!1,this.modalTimeoutMsDraft=null,this.modalMemoryMbDraft=null,this.modalAllowFetchDraft=!0,this.modalPreviewRun=null,this.modalPreviewLogs=[],this.setModalPreviewContext({}),this.setModalPayloadDraft(this.payloadDraft||r),this.setModalSourceDraft(a)},beginEditDraft(){const t=this.selected;this.modalMode="edit",this.modalNameDraft=t?.name||this.selectedName||"",this.modalDescriptionDraft=t?.metadata?.description||"",this.modalEnabledDraft=!1!==t?.enabled,this.modalUnsafeDraft=!0===t?.unsafe,this.modalTimeoutMsDraft=t?.runtime?.timeoutMs??null,this.modalMemoryMbDraft=t?.runtime?.memoryMb??null,this.modalAllowFetchDraft=!1!==t?.runtime?.allowFetch,this.modalPreviewRun=null,this.modalPreviewLogs=[],this.setModalPreviewContext({}),this.setModalPayloadDraft(this.payloadDraft||r),this.setModalSourceDraft(t?.script?.source||this.sourceDraft||a)},buildModalDefinition(){const t={};return Number.isFinite(this.modalTimeoutMsDraft)&&this.modalTimeoutMsDraft>0&&(t.timeoutMs=this.modalTimeoutMsDraft),Number.isFinite(this.modalMemoryMbDraft)&&this.modalMemoryMbDraft>0&&(t.memoryMb=this.modalMemoryMbDraft),t.allowFetch=!1!==this.modalAllowFetchDraft,{name:String(this.modalNameDraft||"").trim(),source:this.modalValidation?.normalizedSource||String(this.modalSourceDraft||"").trim(),metadata:{description:String(this.modalDescriptionDraft||"").trim()},enabled:!1!==this.modalEnabledDraft,unsafe:!0===this.modalUnsafeDraft,runtime:t}},get canSaveModal(){return!(!String(this.modalNameDraft||"").trim()||!this.modalValidation?.ok||this.modalPayloadError||this.saving)},async loadList(){if(!this.functionsBase)return[];this.loading=!0,this.error=null;try{const t=await fetch(this.functionsBase),e=await t.json();return this.items=e?.data||[],this.selectedName&&(this.items.find(t=>t.key===this.selectedName)||this.resetSelection()),this.items}catch(t){throw this.error=t?.message||"Failed to load functions",t}finally{this.loading=!1}},async reloadList(){return this.items=[],this.loadList()},setView(t="overview"){this.currentView="detail"===t?"detail":"overview"},async loadOverviewRuns(t=24){if(!this.functionsBase)return[];const e=(this.items||[]).map(t=>t?.key).filter(Boolean),s=[];for(const t of e){const e=await fetch(`${this.functionsBase}/${encodeURIComponent(t)}/runs`),a=await e.json(),r=(a?.data||[]).map(t=>t?.value?t:{key:t?.id||t?.runId,value:t});s.push(...r)}return s.sort((t,e)=>{const s=t?.value?.execution?.finishedAt??t?.value?.request?.requestedAt??0;return(e?.value?.execution?.finishedAt??e?.value?.request?.requestedAt??0)-s}),this.overviewRuns=s.slice(0,t),this.overviewRuns},async hydrateOverview(){await this.loadList(),await this.loadOverviewRuns()},async select(t){if(this.selectedName=t||null,this.selectedRun=null,this.currentView=t?"detail":"overview",!t)return this.selected=null,this.sourceDraft="",this.runs=[],null;const e=await fetch(`${this.functionsBase}/${encodeURIComponent(t)}`),s=await e.json();if(this.selected=s?.data||null,this.sourceDraft=this.selected?.script?.source||"",this.payloadError=null,await this.loadRuns(t),!this.selectedRun&&this.runs?.length){const t=this.runs[0];this.selectedRun=t?.value||t||null}return this.selected},async loadRuns(t=this.selectedName){if(!t)return this.runs=[],[];const e=await fetch(`${this.functionsBase}/${encodeURIComponent(t)}/runs`),s=await e.json();if(this.runs=s?.data||[],this.selectedRun){const t=this.selectedRun?.id||this.selectedRun?.runId,e=this.runs.map(t=>t?.value||t).find(e=>(e?.id||e?.runId)===t);this.selectedRun=e||null}return this.runs},async refreshSelected(){if(!this.selectedName)return null;const t=this.selectedRun?.id||this.selectedRun?.runId;if(await this.select(this.selectedName),t){const e=this.runs.map(t=>t?.value||t).find(e=>(e?.id||e?.runId)===t);this.selectedRun=e||this.selectedRun}return await this.loadOverviewRuns(),this.selected},setSourceDraft(t){this.sourceDraft=t??""},setPayloadDraft(t){this.payloadDraft=t??r;try{this.parsePayloadDraft(this.payloadDraft),this.payloadError=null}catch(t){this.payloadError=t?.message||"Payload JSON is invalid"}},async create(t={}){this.saving=!0,this.error=null;try{const e={...t},s=await fetch(this.functionsBase,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(e)}),a=await s.json();if(!s.ok)throw new Error(a?.error?.message||a?.data?.error||"Failed to create function");return await this.reloadList(),await this.select(a?.data?.name||t.name),a?.data}finally{this.saving=!1}},async saveSelected(t={}){if(!this.selectedName)return null;this.saving=!0,this.error=null;try{const e={...t,source:t?.source??this.sourceDraft},s=await fetch(`${this.functionsBase}/${encodeURIComponent(this.selectedName)}`,{method:"PUT",headers:{"content-type":"application/json"},body:JSON.stringify(e)}),a=await s.json();if(!s.ok)throw new Error(a?.error?.message||a?.data?.error||"Failed to save function");return await this.reloadList(),await this.select(this.selectedName),a?.data}finally{this.saving=!1}},async saveModalDefinition(){const t=this.buildModalDefinition();return"edit"===this.modalMode&&this.selectedName?await this.saveSelected(t):this.create(t)},async remove(t=this.selectedName){if(!t)return!1;this.saving=!0,this.error=null;try{const e=await fetch(`${this.functionsBase}/${encodeURIComponent(t)}`,{method:"DELETE"});if(!e.ok&&204!==e.status){const t=await e.json().catch(()=>({}));throw new Error(t?.error?.message||t?.data?.error||"Failed to delete function")}return await this.reloadList(),await this.loadOverviewRuns(),this.selectedName===t&&this.resetSelection(),!0}finally{this.saving=!1}},async runSelected(){if(!this.selectedName)return null;this.running=!0,this.error=null;try{let t=null;try{t=this.parsePayloadDraft(this.payloadDraft),this.payloadError=null}catch(t){throw this.payloadError=t?.message||"Payload JSON is invalid",t}const e=await fetch(`${this.functionsBase}/${encodeURIComponent(this.selectedName)}/run`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({payload:t,...this.dryRunMode&&{dryRun:!0}})}),s=await e.json();if(!e.ok){const t=new Error(s?.error?.message||s?.data?.error||"Failed to run function");throw t.code=s?.error?.code||null,t}return await this.loadRuns(this.selectedName),this.selectedRun=n(s?.data||null),this.dryRunMode||!this.selectedRun?.id&&!this.selectedRun?.runId||await this.selectRun(this.selectedRun.id||this.selectedRun.runId),await this.loadOverviewRuns(),this.selectedRun}catch(t){throw this.error=t?.code?`${t.code}: ${t.message}`:t?.message||"Failed to run function",t}finally{this.running=!1}},async runModalDraft(){const t=this.buildModalDefinition();this.modalRunning=!0,this.error=null;try{const e=this.parsePayloadDraft(this.modalPayloadDraft);this.modalPayloadError=null,this.modalPreviewRun=null,this.modalPreviewLogs=[];const s=await fetch(`${this.functionsBase}/preview`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({...t,payload:e,...this.modalDryRunMode&&{dryRun:!0},...this.modalJobContextDraft?{jobContext:n(this.modalJobContextDraft)}:{},...this.modalProcessorContextDraft?{processorContext:n(this.modalProcessorContextDraft)}:{},...this.modalMaterializerContextDraft?{materializerContext:n(this.modalMaterializerContextDraft)}:{}})}),a=await s.json();if(!s.ok)throw new Error(a?.error?.message||a?.data?.error||"Failed to run draft");return this.modalPreviewRun=n(a?.data||null),this.modalPreviewLogs=this.getLogsForRun(this.modalPreviewRun?.id||this.modalPreviewRun?.runId),this.modalPreviewRun}catch(t){throw t instanceof SyntaxError&&(this.modalPayloadError=t?.message||"Payload JSON is invalid"),t}finally{this.modalRunning=!1}},getLogsForRun:t=>t?(s.logs||[]).filter(e=>(e?.runId||e?.meta?.runId)===t):[],refreshModalPreviewLogs(){const t=this.modalPreviewRun?.id||this.modalPreviewRun?.runId;return t?(this.modalPreviewLogs=this.getLogsForRun(t),this.modalPreviewLogs):(this.modalPreviewLogs=[],[])},async selectRun(t){if(!this.selectedName||!t)return this.selectedRun=null,null;const e=await fetch(`${this.functionsBase}/${encodeURIComponent(this.selectedName)}/runs/${encodeURIComponent(t)}`),s=await e.json();return this.selectedRun=s?.data||null,this.selectedRun},async onEnvChanged(){this.resetSelection(),this.beginCreateDraft(),this.currentView="overview",this.hasEnv&&await this.hydrateOverview()}});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
import{ok as s}from"../modules/ok.js";export default s.proxy({selectedEnv:"default",get apiBase(){const s=this.selectedEnv;return s?`${__ENV__.API}/env/${encodeURIComponent(s)}`:`${__ENV__.API}/env`},selectEnv(s){this.selectedEnv!==s&&(this.selectedEnv=s,this.types=null,this._typesPromise=null,this.info=null,this._infoPromise=null)},info:null,_infoPromise:null,async loadInfo(){if(!this.selectedEnv)return null;if(null!==this.info)return this.info;if(!this._infoPromise){this._infoPromise=this._fetchInfo();try{this.info=await this._infoPromise}catch(s){throw this._infoPromise=null,s}}return await this._infoPromise,this.info},async reloadInfo(){return this.info=null,this._infoPromise=null,this.loadInfo()},async _fetchInfo(){if(!this.selectedEnv)return null;const s=await fetch(`${this.apiBase}/info`);if(s.ok)return(await s.json()).data;if(401===s.status||403===s.status)return null;if(404===s.status)return null;throw new Error("Failed to fetch info")},hasPlugin(s){return this.info?.plugins?.includes(s)},types:null,_typesPromise:null,async loadTypes(){if(!this.selectedEnv)return[];if(this.types)return this.types;if(!this._typesPromise){const s=this.apiBase;this._typesPromise=fetch(`${s}/types`).then(async s=>{if(!s.ok){const t=await s.json().catch(()=>({})),e=t?.error,n="string"==typeof e?e:e?.message||`Failed to load types (HTTP ${s.status})`,i=new Error(n);throw i.status=s.status,i}const t=await s.json();return this.types=t?.data??t?.result??[]}).catch(s=>{throw this._typesPromise=null,s})}return this._typesPromise},async reloadTypes(){return this.types=null,this._typesPromise=null,this.loadTypes()},async registerType(s){await fetch(`${this.apiBase}/type/${encodeURIComponent(s)}`,{method:"POST"}),await this.reloadTypes()},envs:null,_envsPromise:null,async loadEnvs(){return this.envs?this.envs:(this._envsPromise||(this._envsPromise=fetch(`${__ENV__.API}/envs`).then(async s=>{if(401===s.status||403===s.status)return this.envs=[],this.selectedEnv=null,[];const{data:t}=await s.json();return this.envs=t||[]}).catch(s=>{throw this._envsPromise=null,s})),this._envsPromise)},async reloadEnvs(){return this.envs=null,this._envsPromise=null,this.loadEnvs()},_pickBestEnv(){const s=(this.envs||[]).filter(s=>!s.name.startsWith("~")&&!s.orphaned);return s.find(s=>s.name===this.selectedEnv)?this.selectedEnv:s[0]?.name??null},async init(){await this.loadEnvs();const s=this._pickBestEnv();s!==this.selectedEnv&&this.selectEnv(s),this.selectedEnv&&await this.loadInfo().catch(()=>{this.info=null})}});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const
|
|
1
|
+
const STORAGE_KEY="okdbTheme",VALID=new Set(["dark","light"]);function readSaved(){try{const e=localStorage.getItem("okdbTheme");return VALID.has(e)?e:null}catch{return null}}function detectPreferred(){return"undefined"!=typeof window&&window.matchMedia&&window.matchMedia("(prefers-color-scheme: light)").matches?"light":"dark"}function apply(e){const t=document.documentElement;"light"===e?t.setAttribute("data-theme","light"):t.removeAttribute("data-theme")}const subscribers=new Set,themeStore={current:readSaved()||detectPreferred(),isExplicit:null!==readSaved(),set(e){if(VALID.has(e)){this.current=e,this.isExplicit=!0;try{localStorage.setItem("okdbTheme",e)}catch{}apply(e);for(const t of subscribers)t(e)}},toggle(){this.set("dark"===this.current?"light":"dark")},subscribe:e=>(subscribers.add(e),()=>subscribers.delete(e))};if(apply(themeStore.current),"undefined"!=typeof window&&window.matchMedia){const e=window.matchMedia("(prefers-color-scheme: light)"),t=e=>{if(!themeStore.isExplicit){themeStore.current=e.matches?"light":"dark",apply(themeStore.current);for(const e of subscribers)e(themeStore.current)}};e.addEventListener?.("change",t)}export default themeStore;
|
|
@@ -1,10 +1,60 @@
|
|
|
1
|
-
<!DOCTYPE html
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html lang="en">
|
|
3
|
+
<head>
|
|
4
|
+
<base href="./">
|
|
5
|
+
<meta charset="UTF-8">
|
|
6
|
+
<title>ok-cron-input test</title>
|
|
7
|
+
<link rel="stylesheet" href="styles.css">
|
|
8
|
+
<script type="importmap">
|
|
9
|
+
{
|
|
2
10
|
"imports": {
|
|
3
11
|
"@toolkit/": "./vendor/okjs/toolkit/",
|
|
4
12
|
"@okjs": "./vendor/okjs/ok.esm.min.js"
|
|
5
13
|
}
|
|
6
|
-
}
|
|
14
|
+
}
|
|
15
|
+
</script>
|
|
16
|
+
<style>
|
|
17
|
+
body { padding: 40px; display:block; height:auto; }
|
|
18
|
+
.demo { max-width:500px; margin:0 auto; display:flex; flex-direction:column; gap:32px; }
|
|
19
|
+
h1 { color:#4FC1FF; font-size:18px; margin:0 0 8px; }
|
|
20
|
+
.row { display:flex; flex-direction:column; gap:6px; }
|
|
21
|
+
label { font-size:12px; color:#6b8a9e; }
|
|
22
|
+
.val { font-family:monospace; font-size:12px; color:#8bb4cc; background:#12171a; padding:4px 8px; border-radius:4px; border:1px solid #2a3035; min-height:22px; }
|
|
23
|
+
</style>
|
|
24
|
+
</head>
|
|
25
|
+
<body>
|
|
26
|
+
<div class="demo">
|
|
27
|
+
<div>
|
|
28
|
+
<h1>ok-cron-input</h1>
|
|
29
|
+
<p style="color:#8899aa;font-size:12px;margin:0">Click the ✏ button to open the cron editor panel.</p>
|
|
30
|
+
</div>
|
|
31
|
+
|
|
32
|
+
<div class="row">
|
|
33
|
+
<label>Cron expression (empty start)</label>
|
|
34
|
+
<ok-cron-input id="c1" @change="document.getElementById('v1').textContent = $event.detail"></ok-cron-input>
|
|
35
|
+
<div class="val" id="v1"></div>
|
|
36
|
+
</div>
|
|
37
|
+
|
|
38
|
+
<div class="row">
|
|
39
|
+
<label>Cron expression (pre-populated)</label>
|
|
40
|
+
<ok-cron-input id="c2" value="*/15 9-17 * * 1-5" @change="document.getElementById('v2').textContent = $event.detail"></ok-cron-input>
|
|
41
|
+
<div class="val" id="v2">*/15 9-17 * * 1-5</div>
|
|
42
|
+
</div>
|
|
43
|
+
|
|
44
|
+
<div class="row">
|
|
45
|
+
<label>Cron expression (disabled)</label>
|
|
46
|
+
<ok-cron-input value="0 12 * * *" disabled></ok-cron-input>
|
|
47
|
+
</div>
|
|
48
|
+
</div>
|
|
49
|
+
|
|
50
|
+
<script type="module">
|
|
51
|
+
import OK from '@okjs';
|
|
7
52
|
import okCronInput from './components/ok-cron-input.ok.js';
|
|
8
53
|
const ok = OK({ env: 'dev' });
|
|
9
54
|
ok.register(okCronInput);
|
|
10
|
-
await ok.init(document.body)
|
|
55
|
+
await ok.init(document.body);
|
|
56
|
+
</script>
|
|
57
|
+
</body>
|
|
58
|
+
</html>
|
|
59
|
+
|
|
60
|
+
|