@feltdb/core 0.4.6 → 0.4.8

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.
@@ -1,3 +1,3 @@
1
- <!doctype html><html lang="en"><head><meta charset="UTF-8"/><meta name="viewport" content="width=device-width,initial-scale=1"/><meta name="theme-color" content="#17211b"/><title>FeltDB Studio</title> <script type="module" crossorigin src="/assets/index-B-lZjdtI.js"></script>
1
+ <!doctype html><html lang="en"><head><meta charset="UTF-8"/><meta name="viewport" content="width=device-width,initial-scale=1"/><meta name="theme-color" content="#17211b"/><title>FeltDB Studio</title> <script type="module" crossorigin src="/assets/index-DKVLtS37.js"></script>
2
2
  <link rel="stylesheet" crossorigin href="/assets/index-CB-Eed9V.css">
3
3
  </head><body><div id="root"></div></body></html>
Binary file
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@feltdb/core",
3
- "version": "0.4.6",
3
+ "version": "0.4.8",
4
4
  "description": "FeltDB Core - Application-facing database API with state-first reactivity",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -1,246 +0,0 @@
1
- import { useEffect as e, useState as t } from "react";
2
- import { jsx as n, jsxs as r } from "react/jsx-runtime";
3
- var i = {
4
- panel: "_panel_1cbba_1",
5
- header: "_header_1cbba_8",
6
- createButton: "_createButton_1cbba_23",
7
- error: "_error_1cbba_38",
8
- createForm: "_createForm_1cbba_47",
9
- formGroup: "_formGroup_1cbba_55",
10
- scopeList: "_scopeList_1cbba_76",
11
- scopeCheckbox: "_scopeCheckbox_1cbba_82",
12
- submitButton: "_submitButton_1cbba_94",
13
- empty: "_empty_1cbba_109",
14
- keysList: "_keysList_1cbba_117",
15
- keyCard: "_keyCard_1cbba_123",
16
- keyHeader: "_keyHeader_1cbba_135",
17
- namespace: "_namespace_1cbba_150",
18
- status: "_status_1cbba_156",
19
- active: "_active_1cbba_163",
20
- expired: "_expired_1cbba_168",
21
- keyDetails: "_keyDetails_1cbba_173",
22
- detail: "_detail_1cbba_179",
23
- copyBtn: "_copyBtn_1cbba_203",
24
- daysLeft: "_daysLeft_1cbba_217",
25
- scopes: "_scopes_1cbba_223",
26
- scopeTags: "_scopeTags_1cbba_227",
27
- scopeTag: "_scopeTag_1cbba_227",
28
- keyActions: "_keyActions_1cbba_243",
29
- revokeBtn: "_revokeBtn_1cbba_250",
30
- info: "_info_1cbba_265"
31
- }, a = ({ apiUrl: a, token: o, namespace: s = "app-store-sherpa" }) => {
32
- let [c, l] = t([]), [u, d] = t(!0), [f, p] = t(null), [m, h] = t(!1), [g, _] = t(null), [v, y] = t(""), [b, x] = t([
33
- "state:read",
34
- "state:write",
35
- "events:read"
36
- ]), S = [
37
- "state:read",
38
- "state:write",
39
- "events:read",
40
- "backup:create",
41
- "backup:restore",
42
- "admin:logs",
43
- "admin:restart"
44
- ], C = [
45
- "state:read",
46
- "state:write",
47
- "events:read",
48
- "backup:create",
49
- "backup:restore",
50
- "admin:logs",
51
- "admin:restart"
52
- ];
53
- e(() => {
54
- w();
55
- }, []);
56
- let w = async () => {
57
- try {
58
- d(!0), p(null);
59
- let e = await fetch(`${a}/api/keys`, { headers: { Authorization: `Bearer ${o}` } });
60
- if (!e.ok) throw Error(`Failed to fetch keys: ${e.statusText}`);
61
- let t = await e.json();
62
- l(t.tokens || []);
63
- } catch (e) {
64
- p(e instanceof Error ? e.message : "Failed to fetch keys");
65
- } finally {
66
- d(!1);
67
- }
68
- }, T = async (e) => {
69
- e.preventDefault();
70
- try {
71
- let e = await fetch(`${a}/api/keys`, {
72
- method: "POST",
73
- headers: {
74
- Authorization: `Bearer ${o}`,
75
- "Content-Type": "application/json"
76
- },
77
- body: JSON.stringify({
78
- id: v || `key-${Date.now()}`,
79
- namespace: s,
80
- scopes: b.length > 0 ? b : C,
81
- expiresIn: 90
82
- })
83
- });
84
- if (!e.ok) throw Error(`Failed to create key: ${e.statusText}`);
85
- y(""), x(C), h(!1), await w();
86
- } catch (e) {
87
- p(e instanceof Error ? e.message : "Failed to create key");
88
- }
89
- }, E = async (e) => {
90
- if (confirm(`Revoke key "${e}"? This cannot be undone.`)) try {
91
- let t = await fetch(`${a}/api/keys/${e}`, {
92
- method: "DELETE",
93
- headers: { Authorization: `Bearer ${o}` }
94
- });
95
- if (!t.ok) throw Error(`Failed to revoke key: ${t.statusText}`);
96
- await w();
97
- } catch (e) {
98
- p(e instanceof Error ? e.message : "Failed to revoke key");
99
- }
100
- }, D = (e, t) => {
101
- navigator.clipboard.writeText(e), _(t), setTimeout(() => _(null), 2e3);
102
- }, O = (e) => new Date(e).toLocaleDateString("en-US", {
103
- year: "numeric",
104
- month: "short",
105
- day: "numeric",
106
- hour: "2-digit",
107
- minute: "2-digit"
108
- }), k = (e) => new Date(e) < /* @__PURE__ */ new Date(), A = (e) => Math.ceil((new Date(e).getTime() - (/* @__PURE__ */ new Date()).getTime()) / 864e5);
109
- return u ? /* @__PURE__ */ n("div", {
110
- className: i.panel,
111
- children: "Loading keys..."
112
- }) : /* @__PURE__ */ r("div", {
113
- className: i.panel,
114
- children: [
115
- /* @__PURE__ */ r("div", {
116
- className: i.header,
117
- children: [/* @__PURE__ */ n("h2", { children: "API Key Management" }), /* @__PURE__ */ n("button", {
118
- className: i.createButton,
119
- onClick: () => h(!m),
120
- children: m ? "✕ Cancel" : "+ New Key"
121
- })]
122
- }),
123
- f && /* @__PURE__ */ r("div", {
124
- className: i.error,
125
- children: ["⚠ ", f]
126
- }),
127
- m && /* @__PURE__ */ r("form", {
128
- onSubmit: T,
129
- className: i.createForm,
130
- children: [
131
- /* @__PURE__ */ r("div", {
132
- className: i.formGroup,
133
- children: [/* @__PURE__ */ n("label", { children: "Key Name (optional)" }), /* @__PURE__ */ n("input", {
134
- type: "text",
135
- value: v,
136
- onChange: (e) => y(e.target.value),
137
- placeholder: "e.g., staging-key-001"
138
- })]
139
- }),
140
- /* @__PURE__ */ r("div", {
141
- className: i.formGroup,
142
- children: [/* @__PURE__ */ n("label", { children: "Scopes" }), /* @__PURE__ */ n("div", {
143
- className: i.scopeList,
144
- children: S.map((e) => /* @__PURE__ */ r("label", {
145
- className: i.scopeCheckbox,
146
- children: [/* @__PURE__ */ n("input", {
147
- type: "checkbox",
148
- checked: b.includes(e),
149
- onChange: (t) => {
150
- t.target.checked ? x([...b, e]) : x(b.filter((t) => t !== e));
151
- }
152
- }), e]
153
- }, e))
154
- })]
155
- }),
156
- /* @__PURE__ */ n("button", {
157
- type: "submit",
158
- className: i.submitButton,
159
- children: "Create Key"
160
- })
161
- ]
162
- }),
163
- c.length === 0 ? /* @__PURE__ */ n("div", {
164
- className: i.empty,
165
- children: "No API keys configured. Create one to get started."
166
- }) : /* @__PURE__ */ n("div", {
167
- className: i.keysList,
168
- children: c.map((e) => /* @__PURE__ */ r("div", {
169
- className: i.keyCard,
170
- children: [
171
- /* @__PURE__ */ r("div", {
172
- className: i.keyHeader,
173
- children: [/* @__PURE__ */ r("div", { children: [/* @__PURE__ */ n("h3", { children: e.id }), /* @__PURE__ */ r("p", {
174
- className: i.namespace,
175
- children: ["Namespace: ", e.namespace]
176
- })] }), /* @__PURE__ */ n("span", {
177
- className: `${i.status} ${k(e.expires_at) ? i.expired : i.active}`,
178
- children: k(e.expires_at) ? "Expired" : "Active"
179
- })]
180
- }),
181
- /* @__PURE__ */ r("div", {
182
- className: i.keyDetails,
183
- children: [
184
- /* @__PURE__ */ r("div", {
185
- className: i.detail,
186
- children: [
187
- /* @__PURE__ */ n("strong", { children: "Secret:" }),
188
- /* @__PURE__ */ r("code", { children: [e.secret.substring(0, 20), "..."] }),
189
- /* @__PURE__ */ n("button", {
190
- className: i.copyBtn,
191
- onClick: () => D(e.secret, e.id),
192
- children: g === e.id ? "✓ Copied" : "Copy"
193
- })
194
- ]
195
- }),
196
- /* @__PURE__ */ r("div", {
197
- className: i.detail,
198
- children: [/* @__PURE__ */ n("strong", { children: "Created:" }), /* @__PURE__ */ n("span", { children: O(e.created_at) })]
199
- }),
200
- /* @__PURE__ */ r("div", {
201
- className: i.detail,
202
- children: [/* @__PURE__ */ n("strong", { children: "Expires:" }), /* @__PURE__ */ r("span", { children: [O(e.expires_at), !k(e.expires_at) && /* @__PURE__ */ r("span", {
203
- className: i.daysLeft,
204
- children: [
205
- "(",
206
- A(e.expires_at),
207
- " days)"
208
- ]
209
- })] })]
210
- }),
211
- e.last_used && /* @__PURE__ */ r("div", {
212
- className: i.detail,
213
- children: [/* @__PURE__ */ n("strong", { children: "Last Used:" }), /* @__PURE__ */ n("span", { children: O(e.last_used) })]
214
- }),
215
- /* @__PURE__ */ r("div", {
216
- className: i.scopes,
217
- children: [/* @__PURE__ */ n("strong", { children: "Scopes:" }), /* @__PURE__ */ n("div", {
218
- className: i.scopeTags,
219
- children: e.scopes.map((e) => /* @__PURE__ */ n("span", {
220
- className: i.scopeTag,
221
- children: e
222
- }, e))
223
- })]
224
- })
225
- ]
226
- }),
227
- /* @__PURE__ */ n("div", {
228
- className: i.keyActions,
229
- children: /* @__PURE__ */ n("button", {
230
- className: i.revokeBtn,
231
- onClick: () => E(e.id),
232
- children: "Revoke"
233
- })
234
- })
235
- ]
236
- }, e.id))
237
- }),
238
- /* @__PURE__ */ n("div", {
239
- className: i.info,
240
- children: /* @__PURE__ */ r("p", { children: [/* @__PURE__ */ n("strong", { children: "Security:" }), " Store tokens securely. Never commit to version control. Tokens expire after 90 days."] })
241
- })
242
- ]
243
- });
244
- };
245
- //#endregion
246
- export { a as t };