@fuzdev/fuz_app 0.60.0 → 0.61.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/ui/AccountSessions.svelte +21 -6
- package/dist/ui/AccountSessions.svelte.d.ts.map +1 -1
- package/dist/ui/AdminAccounts.svelte +32 -25
- package/dist/ui/AdminAccounts.svelte.d.ts.map +1 -1
- package/dist/ui/AdminAuditLog.svelte +3 -3
- package/dist/ui/AdminInvites.svelte +20 -15
- package/dist/ui/AdminOverview.svelte +19 -21
- package/dist/ui/AdminOverview.svelte.d.ts.map +1 -1
- package/dist/ui/AdminRoleGrantHistory.svelte +3 -3
- package/dist/ui/AdminSessions.svelte +19 -21
- package/dist/ui/AdminSessions.svelte.d.ts.map +1 -1
- package/dist/ui/AdminSettings.svelte +1 -3
- package/dist/ui/AdminSettings.svelte.d.ts.map +1 -1
- package/dist/ui/CLAUDE.md +123 -69
- package/dist/ui/ConfirmButton.svelte +82 -24
- package/dist/ui/ConfirmButton.svelte.d.ts +8 -34
- package/dist/ui/ConfirmButton.svelte.d.ts.map +1 -1
- package/dist/ui/OpenSignupToggle.svelte +6 -4
- package/dist/ui/OpenSignupToggle.svelte.d.ts.map +1 -1
- package/dist/ui/RoleGrantOfferForm.svelte +4 -4
- package/dist/ui/RoleGrantOfferHistory.svelte +3 -3
- package/dist/ui/RoleGrantOfferInbox.svelte +10 -6
- package/dist/ui/RoleGrantOfferInbox.svelte.d.ts.map +1 -1
- package/dist/ui/account_sessions_state.svelte.d.ts +17 -7
- package/dist/ui/account_sessions_state.svelte.d.ts.map +1 -1
- package/dist/ui/account_sessions_state.svelte.js +32 -33
- package/dist/ui/admin_accounts_state.svelte.d.ts +48 -17
- package/dist/ui/admin_accounts_state.svelte.d.ts.map +1 -1
- package/dist/ui/admin_accounts_state.svelte.js +58 -76
- package/dist/ui/admin_invites_state.svelte.d.ts +14 -7
- package/dist/ui/admin_invites_state.svelte.d.ts.map +1 -1
- package/dist/ui/admin_invites_state.svelte.js +32 -48
- package/dist/ui/admin_sessions_state.svelte.d.ts +15 -8
- package/dist/ui/admin_sessions_state.svelte.d.ts.map +1 -1
- package/dist/ui/admin_sessions_state.svelte.js +30 -47
- package/dist/ui/app_settings_state.svelte.d.ts +8 -3
- package/dist/ui/app_settings_state.svelte.d.ts.map +1 -1
- package/dist/ui/app_settings_state.svelte.js +19 -27
- package/dist/ui/async_slot.svelte.d.ts +173 -0
- package/dist/ui/async_slot.svelte.d.ts.map +1 -0
- package/dist/ui/async_slot.svelte.js +241 -0
- package/dist/ui/audit_log_state.svelte.d.ts +8 -2
- package/dist/ui/audit_log_state.svelte.d.ts.map +1 -1
- package/dist/ui/audit_log_state.svelte.js +19 -18
- package/dist/ui/keyed_async_slot.svelte.d.ts +139 -0
- package/dist/ui/keyed_async_slot.svelte.d.ts.map +1 -0
- package/dist/ui/keyed_async_slot.svelte.js +177 -0
- package/dist/ui/role_grant_offers_state.svelte.d.ts +39 -7
- package/dist/ui/role_grant_offers_state.svelte.d.ts.map +1 -1
- package/dist/ui/role_grant_offers_state.svelte.js +34 -15
- package/dist/ui/table_state.svelte.d.ts +10 -7
- package/dist/ui/table_state.svelte.d.ts.map +1 -1
- package/dist/ui/table_state.svelte.js +11 -8
- package/package.json +1 -1
- package/dist/ui/loadable.svelte.d.ts +0 -60
- package/dist/ui/loadable.svelte.d.ts.map +0 -1
- package/dist/ui/loadable.svelte.js +0 -80
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Reactive state for database table pagination and data fetching.
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
4
|
+
* Holds one `AsyncSlot` — `list` (the paginated row fetch). Per-row delete
|
|
5
|
+
* uses plain try/catch + scalar `deleting` / `delete_error` fields (no slot
|
|
6
|
+
* — `delete_error` must persist past `list.run()` retries so the failure
|
|
7
|
+
* message stays visible while the user refetches).
|
|
6
8
|
*
|
|
7
9
|
* @example
|
|
8
10
|
* ```ts
|
|
@@ -26,10 +28,10 @@
|
|
|
26
28
|
* table.fetch('accounts');
|
|
27
29
|
* </script>
|
|
28
30
|
*
|
|
29
|
-
* {#if table.loading}
|
|
31
|
+
* {#if table.list.loading}
|
|
30
32
|
* <p>loading…</p>
|
|
31
|
-
* {:else if table.error}
|
|
32
|
-
* <p>{table.error}</p>
|
|
33
|
+
* {:else if table.list.error}
|
|
34
|
+
* <p>{table.list.error}</p>
|
|
33
35
|
* {:else}
|
|
34
36
|
* <p>showing {table.showing_start}–{table.showing_end} of {table.total}</p>
|
|
35
37
|
* {/if}
|
|
@@ -37,12 +39,13 @@
|
|
|
37
39
|
*
|
|
38
40
|
* @module
|
|
39
41
|
*/
|
|
40
|
-
import {
|
|
42
|
+
import { AsyncSlot } from './async_slot.svelte.js';
|
|
41
43
|
import { parse_response_error, ui_fetch } from './ui_fetch.js';
|
|
42
44
|
import { format_value } from './ui_format.js';
|
|
43
45
|
/** Maximum number of rows that can be fetched in a single page. */
|
|
44
46
|
export const TABLE_LIMIT_MAX = 1000;
|
|
45
|
-
export class TableState
|
|
47
|
+
export class TableState {
|
|
48
|
+
list = new AsyncSlot();
|
|
46
49
|
table_name = $state.raw('');
|
|
47
50
|
columns = $state.raw([]);
|
|
48
51
|
rows = $state.raw([]);
|
|
@@ -67,7 +70,7 @@ export class TableState extends Loadable {
|
|
|
67
70
|
this.table_name = table_name;
|
|
68
71
|
this.offset = offset;
|
|
69
72
|
this.limit = Math.max(1, Math.min(TABLE_LIMIT_MAX, limit));
|
|
70
|
-
await this.run(async () => {
|
|
73
|
+
await this.list.run(async () => {
|
|
71
74
|
const response = await ui_fetch(`/api/db/tables/${table_name}?offset=${this.offset}&limit=${this.limit}`);
|
|
72
75
|
if (!response.ok) {
|
|
73
76
|
throw new Error(await parse_response_error(response, 'Failed to fetch table'));
|
package/package.json
CHANGED
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Base reactive state class with loading/error management.
|
|
3
|
-
*
|
|
4
|
-
* Provides the common loading/error pattern shared by all state classes.
|
|
5
|
-
* Subclasses add domain-specific `$state` fields and methods that call
|
|
6
|
-
* the protected `run` helper for async operations.
|
|
7
|
-
*
|
|
8
|
-
* @example
|
|
9
|
-
* ```ts
|
|
10
|
-
* class ItemsState extends Loadable {
|
|
11
|
-
* items: Array<Item> = $state.raw([]);
|
|
12
|
-
*
|
|
13
|
-
* async fetch(): Promise<void> {
|
|
14
|
-
* await this.run(async () => {
|
|
15
|
-
* const response = await fetch('/api/items');
|
|
16
|
-
* if (!response.ok) throw new Error('failed to fetch');
|
|
17
|
-
* this.items = await response.json();
|
|
18
|
-
* });
|
|
19
|
-
* }
|
|
20
|
-
* }
|
|
21
|
-
* ```
|
|
22
|
-
*
|
|
23
|
-
* @example
|
|
24
|
-
* ```ts
|
|
25
|
-
* // structured errors via map_error
|
|
26
|
-
* class FormState extends Loadable<{field: string; message: string}> {
|
|
27
|
-
* async submit(data: FormData): Promise<void> {
|
|
28
|
-
* await this.run(
|
|
29
|
-
* () => post_form(data),
|
|
30
|
-
* (e) => ({field: 'form', message: e instanceof Error ? e.message : 'unknown'}),
|
|
31
|
-
* );
|
|
32
|
-
* }
|
|
33
|
-
* }
|
|
34
|
-
* ```
|
|
35
|
-
*
|
|
36
|
-
* @module
|
|
37
|
-
*/
|
|
38
|
-
export declare class Loadable<TError = string> {
|
|
39
|
-
loading: boolean;
|
|
40
|
-
error: TError | null;
|
|
41
|
-
/** The raw caught value from the last failed `run()`, for programmatic inspection. */
|
|
42
|
-
error_data: unknown;
|
|
43
|
-
/**
|
|
44
|
-
* Run an async operation with loading/error handling.
|
|
45
|
-
*
|
|
46
|
-
* Sets `loading` to `true`, clears `error` and `error_data`, runs `fn`, catches errors.
|
|
47
|
-
* Pass `map_error` to produce structured errors instead of strings.
|
|
48
|
-
*
|
|
49
|
-
* @returns the result or `undefined` if the operation failed
|
|
50
|
-
* @mutates `this`
|
|
51
|
-
*/
|
|
52
|
-
protected run<T>(fn: () => Promise<T>, map_error?: (e: unknown) => TError): Promise<T | undefined>;
|
|
53
|
-
/**
|
|
54
|
-
* Reset loading and error state. Subclasses override to clear data.
|
|
55
|
-
*
|
|
56
|
-
* @mutates `this`
|
|
57
|
-
*/
|
|
58
|
-
reset(): void;
|
|
59
|
-
}
|
|
60
|
-
//# sourceMappingURL=loadable.svelte.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"loadable.svelte.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/ui/loadable.svelte.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCG;AAEH,qBAAa,QAAQ,CAAC,MAAM,GAAG,MAAM;IACpC,OAAO,UAAqB;IAC5B,KAAK,EAAE,MAAM,GAAG,IAAI,CAAoB;IAExC,sFAAsF;IACtF,UAAU,EAAE,OAAO,CAAoB;IAEvC;;;;;;;;OAQG;cACa,GAAG,CAAC,CAAC,EACpB,EAAE,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,EACpB,SAAS,CAAC,EAAE,CAAC,CAAC,EAAE,OAAO,KAAK,MAAM,GAChC,OAAO,CAAC,CAAC,GAAG,SAAS,CAAC;IAiBzB;;;;OAIG;IACH,KAAK,IAAI,IAAI;CAKb"}
|
|
@@ -1,80 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Base reactive state class with loading/error management.
|
|
3
|
-
*
|
|
4
|
-
* Provides the common loading/error pattern shared by all state classes.
|
|
5
|
-
* Subclasses add domain-specific `$state` fields and methods that call
|
|
6
|
-
* the protected `run` helper for async operations.
|
|
7
|
-
*
|
|
8
|
-
* @example
|
|
9
|
-
* ```ts
|
|
10
|
-
* class ItemsState extends Loadable {
|
|
11
|
-
* items: Array<Item> = $state.raw([]);
|
|
12
|
-
*
|
|
13
|
-
* async fetch(): Promise<void> {
|
|
14
|
-
* await this.run(async () => {
|
|
15
|
-
* const response = await fetch('/api/items');
|
|
16
|
-
* if (!response.ok) throw new Error('failed to fetch');
|
|
17
|
-
* this.items = await response.json();
|
|
18
|
-
* });
|
|
19
|
-
* }
|
|
20
|
-
* }
|
|
21
|
-
* ```
|
|
22
|
-
*
|
|
23
|
-
* @example
|
|
24
|
-
* ```ts
|
|
25
|
-
* // structured errors via map_error
|
|
26
|
-
* class FormState extends Loadable<{field: string; message: string}> {
|
|
27
|
-
* async submit(data: FormData): Promise<void> {
|
|
28
|
-
* await this.run(
|
|
29
|
-
* () => post_form(data),
|
|
30
|
-
* (e) => ({field: 'form', message: e instanceof Error ? e.message : 'unknown'}),
|
|
31
|
-
* );
|
|
32
|
-
* }
|
|
33
|
-
* }
|
|
34
|
-
* ```
|
|
35
|
-
*
|
|
36
|
-
* @module
|
|
37
|
-
*/
|
|
38
|
-
export class Loadable {
|
|
39
|
-
loading = $state.raw(false);
|
|
40
|
-
error = $state.raw(null);
|
|
41
|
-
/** The raw caught value from the last failed `run()`, for programmatic inspection. */
|
|
42
|
-
error_data = $state.raw(null);
|
|
43
|
-
/**
|
|
44
|
-
* Run an async operation with loading/error handling.
|
|
45
|
-
*
|
|
46
|
-
* Sets `loading` to `true`, clears `error` and `error_data`, runs `fn`, catches errors.
|
|
47
|
-
* Pass `map_error` to produce structured errors instead of strings.
|
|
48
|
-
*
|
|
49
|
-
* @returns the result or `undefined` if the operation failed
|
|
50
|
-
* @mutates `this`
|
|
51
|
-
*/
|
|
52
|
-
async run(fn, map_error) {
|
|
53
|
-
this.loading = true;
|
|
54
|
-
this.error = null;
|
|
55
|
-
this.error_data = null;
|
|
56
|
-
try {
|
|
57
|
-
return await fn();
|
|
58
|
-
}
|
|
59
|
-
catch (e) {
|
|
60
|
-
this.error = map_error
|
|
61
|
-
? map_error(e)
|
|
62
|
-
: (e instanceof Error ? e.message : 'Request failed');
|
|
63
|
-
this.error_data = e;
|
|
64
|
-
return undefined;
|
|
65
|
-
}
|
|
66
|
-
finally {
|
|
67
|
-
this.loading = false;
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
/**
|
|
71
|
-
* Reset loading and error state. Subclasses override to clear data.
|
|
72
|
-
*
|
|
73
|
-
* @mutates `this`
|
|
74
|
-
*/
|
|
75
|
-
reset() {
|
|
76
|
-
this.loading = false;
|
|
77
|
-
this.error = null;
|
|
78
|
-
this.error_data = null;
|
|
79
|
-
}
|
|
80
|
-
}
|