@fuzdev/fuz_app 0.31.0 → 0.33.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/actions/rpc_client.d.ts +29 -0
- package/dist/actions/rpc_client.d.ts.map +1 -1
- package/dist/actions/rpc_client.js +31 -0
- package/dist/auth/CLAUDE.md +22 -0
- package/dist/auth/admin_rpc_actions.d.ts +49 -0
- package/dist/auth/admin_rpc_actions.d.ts.map +1 -0
- package/dist/auth/admin_rpc_actions.js +32 -0
- package/dist/server/app_server.d.ts +13 -2
- package/dist/server/app_server.d.ts.map +1 -1
- package/dist/server/app_server.js +12 -1
- package/dist/testing/CLAUDE.md +26 -10
- package/dist/testing/admin_integration.d.ts +14 -4
- package/dist/testing/admin_integration.d.ts.map +1 -1
- package/dist/testing/admin_integration.js +7 -4
- package/dist/testing/app_server.d.ts +10 -0
- package/dist/testing/app_server.d.ts.map +1 -1
- package/dist/testing/audit_completeness.d.ts +13 -4
- package/dist/testing/audit_completeness.d.ts.map +1 -1
- package/dist/testing/audit_completeness.js +8 -5
- package/dist/testing/integration.d.ts +14 -4
- package/dist/testing/integration.d.ts.map +1 -1
- package/dist/testing/integration.js +16 -6
- package/dist/testing/rate_limiting.d.ts +13 -4
- package/dist/testing/rate_limiting.d.ts.map +1 -1
- package/dist/testing/rate_limiting.js +9 -3
- package/dist/testing/rpc_helpers.d.ts +29 -0
- package/dist/testing/rpc_helpers.d.ts.map +1 -1
- package/dist/testing/rpc_helpers.js +20 -0
- package/dist/testing/rpc_round_trip.d.ts +16 -5
- package/dist/testing/rpc_round_trip.d.ts.map +1 -1
- package/dist/testing/rpc_round_trip.js +11 -5
- package/dist/testing/sse_round_trip.d.ts +13 -5
- package/dist/testing/sse_round_trip.d.ts.map +1 -1
- package/dist/testing/sse_round_trip.js +11 -5
- package/dist/testing/standard.d.ts +7 -2
- package/dist/testing/standard.d.ts.map +1 -1
- package/dist/testing/stubs.d.ts +10 -2
- package/dist/testing/stubs.d.ts.map +1 -1
- package/dist/testing/stubs.js +17 -2
- package/dist/ui/CLAUDE.md +12 -0
- package/dist/ui/admin_rpc_adapters.d.ts +94 -0
- package/dist/ui/admin_rpc_adapters.d.ts.map +1 -0
- package/dist/ui/admin_rpc_adapters.js +100 -0
- package/package.json +1 -1
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Admin RPC adapter helpers for consumer UIs.
|
|
3
|
+
*
|
|
4
|
+
* Bridges a typed `rpc_call`-shaped function to the four narrow admin RPC
|
|
5
|
+
* interfaces the state classes consume — `AdminAccountsRpc`,
|
|
6
|
+
* `AdminInvitesRpc`, `AuditLogRpc`, `AppSettingsRpc`. Two calls at the
|
|
7
|
+
* admin shell layout wire everything:
|
|
8
|
+
*
|
|
9
|
+
* ```ts
|
|
10
|
+
* import {create_throwing_rpc_call} from '@fuzdev/fuz_app/actions/rpc_client.js';
|
|
11
|
+
* const rpc_call = create_throwing_rpc_call(api);
|
|
12
|
+
* provide_admin_rpc_contexts(create_admin_rpc_adapters(rpc_call));
|
|
13
|
+
* ```
|
|
14
|
+
*
|
|
15
|
+
* `create_throwing_rpc_call` unwraps every `Result` to throw on error, spreading
|
|
16
|
+
* the JSON-RPC `{code, message, data?}` onto the thrown `Error` so form
|
|
17
|
+
* components (e.g. `PermitOfferForm.svelte`) can match on
|
|
18
|
+
* `error.data?.reason` via `ERROR_OFFER_*` constants — optional chaining is
|
|
19
|
+
* required because JSON-RPC `data` is spec-level optional. Consumers that
|
|
20
|
+
* need a custom unwrap strategy can supply any function matching
|
|
21
|
+
* `AdminRpcCall` directly instead.
|
|
22
|
+
*
|
|
23
|
+
* No `.svelte.ts` suffix — this module holds no reactive state, only
|
|
24
|
+
* method-name mappings.
|
|
25
|
+
*
|
|
26
|
+
* @module
|
|
27
|
+
*/
|
|
28
|
+
import type { ThrowingRpcCall } from '../actions/rpc_client.js';
|
|
29
|
+
import { type AdminAccountsRpc } from './admin_accounts_state.svelte.js';
|
|
30
|
+
import { type AdminInvitesRpc } from './admin_invites_state.svelte.js';
|
|
31
|
+
import { type AuditLogRpc } from './audit_log_state.svelte.js';
|
|
32
|
+
import { type AppSettingsRpc } from './app_settings_state.svelte.js';
|
|
33
|
+
/**
|
|
34
|
+
* Function-shaped contract for dispatching an RPC call by method name.
|
|
35
|
+
*
|
|
36
|
+
* Alias of `ThrowingRpcCall` — kept as a domain-specific name so reads of
|
|
37
|
+
* the admin UI code stay self-contained. Receives the method string and
|
|
38
|
+
* input, returns a Promise of the output — or throws on error carrying the
|
|
39
|
+
* JSON-RPC `{code, message, data?}` shape.
|
|
40
|
+
*
|
|
41
|
+
* The generic is load-bearing: contextual typing lets the narrow
|
|
42
|
+
* `Admin*Rpc` return types flow into `TOutput` so adapter methods typecheck
|
|
43
|
+
* without explicit casts.
|
|
44
|
+
*/
|
|
45
|
+
export type AdminRpcCall = ThrowingRpcCall;
|
|
46
|
+
/** The four admin RPC adapters assembled from a shared `rpc_call`. */
|
|
47
|
+
export interface AdminRpcAdapters {
|
|
48
|
+
admin_accounts: AdminAccountsRpc;
|
|
49
|
+
admin_invites: AdminInvitesRpc;
|
|
50
|
+
audit_log: AuditLogRpc;
|
|
51
|
+
app_settings: AppSettingsRpc;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Build the four admin RPC adapters from a single typed `rpc_call`.
|
|
55
|
+
*
|
|
56
|
+
* Method-name mapping:
|
|
57
|
+
*
|
|
58
|
+
* | Narrow RPC method | Action spec method |
|
|
59
|
+
* | ----------------------------------- | ---------------------------- |
|
|
60
|
+
* | `admin_accounts.list_accounts` | `admin_account_list` |
|
|
61
|
+
* | `admin_accounts.list_sessions` | `admin_session_list` |
|
|
62
|
+
* | `admin_accounts.grant_permit` | `permit_offer_create` |
|
|
63
|
+
* | `admin_accounts.revoke_permit` | `permit_revoke` |
|
|
64
|
+
* | `admin_accounts.retract_offer` | `permit_offer_retract` |
|
|
65
|
+
* | `admin_accounts.session_revoke_all` | `admin_session_revoke_all` |
|
|
66
|
+
* | `admin_accounts.token_revoke_all` | `admin_token_revoke_all` |
|
|
67
|
+
* | `admin_invites.list` | `invite_list` |
|
|
68
|
+
* | `admin_invites.create` | `invite_create` |
|
|
69
|
+
* | `admin_invites.delete` | `invite_delete` |
|
|
70
|
+
* | `audit_log.list` | `audit_log_list` |
|
|
71
|
+
* | `audit_log.permit_history` | `audit_log_permit_history` |
|
|
72
|
+
* | `app_settings.get` | `app_settings_get` |
|
|
73
|
+
* | `app_settings.update` | `app_settings_update` |
|
|
74
|
+
*
|
|
75
|
+
* All four adapter factories call through the same `rpc_call` — consumers
|
|
76
|
+
* only construct one adapter closure (typically wrapping
|
|
77
|
+
* `create_rpc_client`'s Proxy + Result-unwrap) regardless of how many
|
|
78
|
+
* admin surfaces they mount.
|
|
79
|
+
*/
|
|
80
|
+
export declare const create_admin_rpc_adapters: (rpc_call: AdminRpcCall) => AdminRpcAdapters;
|
|
81
|
+
/**
|
|
82
|
+
* Wire all four admin RPC contexts in a single call.
|
|
83
|
+
*
|
|
84
|
+
* Call once at the admin shell layout (e.g. `src/routes/admin/+layout.svelte`)
|
|
85
|
+
* with adapters built from `create_admin_rpc_adapters`. Every `Admin*.svelte`
|
|
86
|
+
* component that reads a context below this point sees the adapters.
|
|
87
|
+
*
|
|
88
|
+
* Each context accessor reads `adapters.{domain}` on every invocation, so
|
|
89
|
+
* mutating an adapter field on the same object propagates. Replacing the
|
|
90
|
+
* whole adapter set requires calling `provide_admin_rpc_contexts` again
|
|
91
|
+
* during init — in practice this is one-shot at layout mount.
|
|
92
|
+
*/
|
|
93
|
+
export declare const provide_admin_rpc_contexts: (adapters: AdminRpcAdapters) => void;
|
|
94
|
+
//# sourceMappingURL=admin_rpc_adapters.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"admin_rpc_adapters.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/ui/admin_rpc_adapters.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAEH,OAAO,KAAK,EAAC,eAAe,EAAC,MAAM,0BAA0B,CAAC;AAC9D,OAAO,EAA6B,KAAK,gBAAgB,EAAC,MAAM,kCAAkC,CAAC;AACnG,OAAO,EAA4B,KAAK,eAAe,EAAC,MAAM,iCAAiC,CAAC;AAChG,OAAO,EAAwB,KAAK,WAAW,EAAC,MAAM,6BAA6B,CAAC;AACpF,OAAO,EAA2B,KAAK,cAAc,EAAC,MAAM,gCAAgC,CAAC;AAE7F;;;;;;;;;;;GAWG;AACH,MAAM,MAAM,YAAY,GAAG,eAAe,CAAC;AAE3C,sEAAsE;AACtE,MAAM,WAAW,gBAAgB;IAChC,cAAc,EAAE,gBAAgB,CAAC;IACjC,aAAa,EAAE,eAAe,CAAC;IAC/B,SAAS,EAAE,WAAW,CAAC;IACvB,YAAY,EAAE,cAAc,CAAC;CAC7B;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,eAAO,MAAM,yBAAyB,GAAI,UAAU,YAAY,KAAG,gBAuBjE,CAAC;AAEH;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,0BAA0B,GAAI,UAAU,gBAAgB,KAAG,IAKvE,CAAC"}
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Admin RPC adapter helpers for consumer UIs.
|
|
3
|
+
*
|
|
4
|
+
* Bridges a typed `rpc_call`-shaped function to the four narrow admin RPC
|
|
5
|
+
* interfaces the state classes consume — `AdminAccountsRpc`,
|
|
6
|
+
* `AdminInvitesRpc`, `AuditLogRpc`, `AppSettingsRpc`. Two calls at the
|
|
7
|
+
* admin shell layout wire everything:
|
|
8
|
+
*
|
|
9
|
+
* ```ts
|
|
10
|
+
* import {create_throwing_rpc_call} from '@fuzdev/fuz_app/actions/rpc_client.js';
|
|
11
|
+
* const rpc_call = create_throwing_rpc_call(api);
|
|
12
|
+
* provide_admin_rpc_contexts(create_admin_rpc_adapters(rpc_call));
|
|
13
|
+
* ```
|
|
14
|
+
*
|
|
15
|
+
* `create_throwing_rpc_call` unwraps every `Result` to throw on error, spreading
|
|
16
|
+
* the JSON-RPC `{code, message, data?}` onto the thrown `Error` so form
|
|
17
|
+
* components (e.g. `PermitOfferForm.svelte`) can match on
|
|
18
|
+
* `error.data?.reason` via `ERROR_OFFER_*` constants — optional chaining is
|
|
19
|
+
* required because JSON-RPC `data` is spec-level optional. Consumers that
|
|
20
|
+
* need a custom unwrap strategy can supply any function matching
|
|
21
|
+
* `AdminRpcCall` directly instead.
|
|
22
|
+
*
|
|
23
|
+
* No `.svelte.ts` suffix — this module holds no reactive state, only
|
|
24
|
+
* method-name mappings.
|
|
25
|
+
*
|
|
26
|
+
* @module
|
|
27
|
+
*/
|
|
28
|
+
import { admin_accounts_rpc_context } from './admin_accounts_state.svelte.js';
|
|
29
|
+
import { admin_invites_rpc_context } from './admin_invites_state.svelte.js';
|
|
30
|
+
import { audit_log_rpc_context } from './audit_log_state.svelte.js';
|
|
31
|
+
import { app_settings_rpc_context } from './app_settings_state.svelte.js';
|
|
32
|
+
/**
|
|
33
|
+
* Build the four admin RPC adapters from a single typed `rpc_call`.
|
|
34
|
+
*
|
|
35
|
+
* Method-name mapping:
|
|
36
|
+
*
|
|
37
|
+
* | Narrow RPC method | Action spec method |
|
|
38
|
+
* | ----------------------------------- | ---------------------------- |
|
|
39
|
+
* | `admin_accounts.list_accounts` | `admin_account_list` |
|
|
40
|
+
* | `admin_accounts.list_sessions` | `admin_session_list` |
|
|
41
|
+
* | `admin_accounts.grant_permit` | `permit_offer_create` |
|
|
42
|
+
* | `admin_accounts.revoke_permit` | `permit_revoke` |
|
|
43
|
+
* | `admin_accounts.retract_offer` | `permit_offer_retract` |
|
|
44
|
+
* | `admin_accounts.session_revoke_all` | `admin_session_revoke_all` |
|
|
45
|
+
* | `admin_accounts.token_revoke_all` | `admin_token_revoke_all` |
|
|
46
|
+
* | `admin_invites.list` | `invite_list` |
|
|
47
|
+
* | `admin_invites.create` | `invite_create` |
|
|
48
|
+
* | `admin_invites.delete` | `invite_delete` |
|
|
49
|
+
* | `audit_log.list` | `audit_log_list` |
|
|
50
|
+
* | `audit_log.permit_history` | `audit_log_permit_history` |
|
|
51
|
+
* | `app_settings.get` | `app_settings_get` |
|
|
52
|
+
* | `app_settings.update` | `app_settings_update` |
|
|
53
|
+
*
|
|
54
|
+
* All four adapter factories call through the same `rpc_call` — consumers
|
|
55
|
+
* only construct one adapter closure (typically wrapping
|
|
56
|
+
* `create_rpc_client`'s Proxy + Result-unwrap) regardless of how many
|
|
57
|
+
* admin surfaces they mount.
|
|
58
|
+
*/
|
|
59
|
+
export const create_admin_rpc_adapters = (rpc_call) => ({
|
|
60
|
+
admin_accounts: {
|
|
61
|
+
list_accounts: () => rpc_call('admin_account_list', null),
|
|
62
|
+
list_sessions: () => rpc_call('admin_session_list', null),
|
|
63
|
+
grant_permit: (params) => rpc_call('permit_offer_create', params),
|
|
64
|
+
revoke_permit: (params) => rpc_call('permit_revoke', params),
|
|
65
|
+
retract_offer: (offer_id) => rpc_call('permit_offer_retract', { offer_id }),
|
|
66
|
+
session_revoke_all: (params) => rpc_call('admin_session_revoke_all', params),
|
|
67
|
+
token_revoke_all: (params) => rpc_call('admin_token_revoke_all', params),
|
|
68
|
+
},
|
|
69
|
+
admin_invites: {
|
|
70
|
+
list: () => rpc_call('invite_list', null),
|
|
71
|
+
create: (params) => rpc_call('invite_create', params),
|
|
72
|
+
delete: (params) => rpc_call('invite_delete', params),
|
|
73
|
+
},
|
|
74
|
+
audit_log: {
|
|
75
|
+
list: (options) => rpc_call('audit_log_list', options ?? {}),
|
|
76
|
+
permit_history: (params) => rpc_call('audit_log_permit_history', params ?? {}),
|
|
77
|
+
},
|
|
78
|
+
app_settings: {
|
|
79
|
+
get: () => rpc_call('app_settings_get', null),
|
|
80
|
+
update: (params) => rpc_call('app_settings_update', params),
|
|
81
|
+
},
|
|
82
|
+
});
|
|
83
|
+
/**
|
|
84
|
+
* Wire all four admin RPC contexts in a single call.
|
|
85
|
+
*
|
|
86
|
+
* Call once at the admin shell layout (e.g. `src/routes/admin/+layout.svelte`)
|
|
87
|
+
* with adapters built from `create_admin_rpc_adapters`. Every `Admin*.svelte`
|
|
88
|
+
* component that reads a context below this point sees the adapters.
|
|
89
|
+
*
|
|
90
|
+
* Each context accessor reads `adapters.{domain}` on every invocation, so
|
|
91
|
+
* mutating an adapter field on the same object propagates. Replacing the
|
|
92
|
+
* whole adapter set requires calling `provide_admin_rpc_contexts` again
|
|
93
|
+
* during init — in practice this is one-shot at layout mount.
|
|
94
|
+
*/
|
|
95
|
+
export const provide_admin_rpc_contexts = (adapters) => {
|
|
96
|
+
admin_accounts_rpc_context.set(() => adapters.admin_accounts);
|
|
97
|
+
admin_invites_rpc_context.set(() => adapters.admin_invites);
|
|
98
|
+
audit_log_rpc_context.set(() => adapters.audit_log);
|
|
99
|
+
app_settings_rpc_context.set(() => adapters.app_settings);
|
|
100
|
+
};
|