@decaf-ts/ui-decorators 0.18.0 → 0.19.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-decorators.cjs +1 -1
- package/lib/cjs/graph/constants.cjs +28 -1
- package/lib/cjs/graph/constants.cjs.map +1 -1
- package/lib/cjs/index.cjs +3 -3
- package/lib/cjs/user-requests/UserRequestHandler.cjs +190 -0
- package/lib/cjs/user-requests/UserRequestHandler.cjs.map +1 -0
- package/lib/cjs/user-requests/constants.cjs +22 -0
- package/lib/cjs/user-requests/constants.cjs.map +1 -0
- package/lib/cjs/user-requests/decorators.cjs +41 -0
- package/lib/cjs/user-requests/decorators.cjs.map +1 -0
- package/lib/cjs/user-requests/errors.cjs +26 -0
- package/lib/cjs/user-requests/errors.cjs.map +1 -0
- package/lib/cjs/user-requests/index.cjs +33 -0
- package/lib/cjs/user-requests/index.cjs.map +1 -0
- package/lib/cjs/user-requests/types.cjs +4 -0
- package/lib/cjs/user-requests/types.cjs.map +1 -0
- package/lib/esm/graph/constants.js +26 -0
- package/lib/esm/graph/constants.js.map +1 -1
- package/lib/esm/index.js +3 -3
- package/lib/esm/user-requests/UserRequestHandler.js +185 -0
- package/lib/esm/user-requests/UserRequestHandler.js.map +1 -0
- package/lib/esm/user-requests/constants.js +18 -0
- package/lib/esm/user-requests/constants.js.map +1 -0
- package/lib/esm/user-requests/decorators.js +37 -0
- package/lib/esm/user-requests/decorators.js.map +1 -0
- package/lib/esm/user-requests/errors.js +21 -0
- package/lib/esm/user-requests/errors.js.map +1 -0
- package/lib/esm/user-requests/index.js +16 -0
- package/lib/esm/user-requests/index.js.map +1 -0
- package/lib/esm/user-requests/types.js +8 -0
- package/lib/esm/user-requests/types.js.map +1 -0
- package/lib/types/graph/constants.d.cts +66 -0
- package/lib/types/graph/constants.d.mts +66 -0
- package/lib/types/index.d.cts +3 -3
- package/lib/types/index.d.mts +3 -3
- package/lib/types/user-requests/UserRequestHandler.d.cts +117 -0
- package/lib/types/user-requests/UserRequestHandler.d.mts +117 -0
- package/lib/types/user-requests/constants.d.cts +17 -0
- package/lib/types/user-requests/constants.d.mts +17 -0
- package/lib/types/user-requests/decorators.d.cts +22 -0
- package/lib/types/user-requests/decorators.d.mts +22 -0
- package/lib/types/user-requests/errors.d.cts +18 -0
- package/lib/types/user-requests/errors.d.mts +18 -0
- package/lib/types/user-requests/index.d.cts +15 -0
- package/lib/types/user-requests/index.d.mts +15 -0
- package/lib/types/user-requests/types.d.cts +36 -0
- package/lib/types/user-requests/types.d.mts +36 -0
- package/package.json +22 -4
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module ui-decorators/user-requests/UserRequestHandler
|
|
3
|
+
* @summary Service-based base class for user request handlers.
|
|
4
|
+
* @description No Angular or DOM imports — safe for pure-Node (backend) bundles.
|
|
5
|
+
*
|
|
6
|
+
* Handlers extend `Service`, receive a rendering-engine facade as a
|
|
7
|
+
* `protected readonly` property and implement `handle`, either returning the
|
|
8
|
+
* resolved value or throwing (a `CancelledError` when the user cancels
|
|
9
|
+
* mid-request). Lookup and dispatch are static: `@userRequest(reference)`
|
|
10
|
+
* records the class as metadata and `UserRequestHandler.getHandler(reference)`
|
|
11
|
+
* / `UserRequestHandler.handle(request, renderingEngine)` resolve and run it,
|
|
12
|
+
* so no process-wide registry instance is needed.
|
|
13
|
+
*/
|
|
14
|
+
import { Context, ContextFlags, ContextualArgs, FlagsOf, LoggerOf, MaybeContextualArg, MethodOrOperation, Service } from "@decaf-ts/core";
|
|
15
|
+
import { Constructor } from "@decaf-ts/decoration";
|
|
16
|
+
import type { RenderingFacade, UserRequest, UserRequestHandlerMetadata } from "./types.d.mts";
|
|
17
|
+
/**
|
|
18
|
+
* @description Result of `UserRequestHandler.logCtx(...)`. Extends the
|
|
19
|
+
* standard `{ log, ctx, ctxArgs }` surface with the exact `RenderingEngine`
|
|
20
|
+
* methods a handler needs (`modal`/`toast`/`spinner`/`router`) wrapping the
|
|
21
|
+
* rendering engine handed to the handler constructor. The keys mirror the
|
|
22
|
+
* underlying engine methods without a `get` prefix, and no duplicated
|
|
23
|
+
* `UserRequest*` rendering types are introduced.
|
|
24
|
+
* @summary Contextual surface returned by `UserRequestHandler.logCtx(*, *, true)`.
|
|
25
|
+
* @template C The decaf context the handler service runs under.
|
|
26
|
+
* @template ARGS The contextual argument tuple passed to the call.
|
|
27
|
+
*/
|
|
28
|
+
export interface UserRequestLogContext<C extends Context<ContextFlags<any>> = Context<ContextFlags<any>>, ARGS extends any[] = any[]> {
|
|
29
|
+
log: LoggerOf<C>;
|
|
30
|
+
ctx: C;
|
|
31
|
+
ctxArgs: ContextualArgs<C, ARGS>;
|
|
32
|
+
readonly modal: RenderingFacade["getModal"];
|
|
33
|
+
readonly toast: RenderingFacade["getToast"];
|
|
34
|
+
readonly spinner: RenderingFacade["getSpinner"];
|
|
35
|
+
readonly router: RenderingFacade["router"];
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* @description Abstract base class for user request handlers.
|
|
39
|
+
*
|
|
40
|
+
* Handler methods follow the core `Service` golden rules: `handle` (and the
|
|
41
|
+
* lifecycle helpers `getInput`/`cancel`) accept rest contextual args
|
|
42
|
+
* (`...args: ContextualArgs<C>`) and obtain their `{ log, ctx, ctxArgs }` via
|
|
43
|
+
* `this.logCtx([request, ...args], this.handle, true)` — entry and resolution
|
|
44
|
+
* via `log.info`, transitions via `log.verbose`, payload details via
|
|
45
|
+
* `log.debug` and failures/cancellations via `log.error`. A `CancelledError`
|
|
46
|
+
* is thrown when the user cancels mid-request. `handle` is the one async
|
|
47
|
+
* method handlers override, returning the resolved value or throwing.
|
|
48
|
+
* @summary Service-based base class implementing the user request lifecycle.
|
|
49
|
+
* @template T The resolved payload type the handler returns.
|
|
50
|
+
* @template C The decaf context the service runs under.
|
|
51
|
+
*/
|
|
52
|
+
export declare abstract class UserRequestHandler<T = unknown, C extends Context<ContextFlags<any>> = Context<ContextFlags<any>>> extends Service<C> {
|
|
53
|
+
protected readonly renderingEngine: RenderingFacade;
|
|
54
|
+
private currentModal?;
|
|
55
|
+
private cancelled;
|
|
56
|
+
private submitted?;
|
|
57
|
+
private dismissed?;
|
|
58
|
+
/**
|
|
59
|
+
* @description Creates a handler bound to the given rendering-engine facade.
|
|
60
|
+
* The facade is the only external dependency: no context/resolver
|
|
61
|
+
* indirection.
|
|
62
|
+
* @param {RenderingFacade} renderingEngine The rendering-engine surface the
|
|
63
|
+
* handler drives (modal, toast, spinner and router).
|
|
64
|
+
*/
|
|
65
|
+
protected constructor(renderingEngine: RenderingFacade);
|
|
66
|
+
/**
|
|
67
|
+
* @description Resolves the handler class registered for the given request
|
|
68
|
+
* reference via `Metadata`. Handlers are recorded by the `@userRequest`
|
|
69
|
+
* decorator under `USER_REQUEST_KEY`.
|
|
70
|
+
* @param {string} reference The request id/type the handler is registered
|
|
71
|
+
* for.
|
|
72
|
+
* @return {.Constructor<UserRequestHandler> | undefined}
|
|
73
|
+
* The registered handler constructor, or `undefined` when unknown.
|
|
74
|
+
*/
|
|
75
|
+
static getHandler(reference: string): Constructor<UserRequestHandler> | undefined;
|
|
76
|
+
/**
|
|
77
|
+
* @description Reads the `@userRequest` metadata recorded on a handler class
|
|
78
|
+
* via `Metadata`.
|
|
79
|
+
* @param {object} target The handler class to inspect.
|
|
80
|
+
* @return {UserRequestHandlerMetadata | undefined} The recorded metadata
|
|
81
|
+
* `{ reference }`, or `undefined` when the class is not decorated.
|
|
82
|
+
*/
|
|
83
|
+
static getMetadata(target: object): UserRequestHandlerMetadata | undefined;
|
|
84
|
+
static handle<T = unknown>(request: UserRequest<T>, renderingEngine: RenderingFacade): Promise<T>;
|
|
85
|
+
protected getInput(request: UserRequest<T>, ...args: ContextualArgs<C>): Promise<T>;
|
|
86
|
+
private awaitDismissal;
|
|
87
|
+
cancel(...args: ContextualArgs<C> | []): Promise<void>;
|
|
88
|
+
abstract handle(request: UserRequest<T>, ...args: ContextualArgs<C>): Promise<T>;
|
|
89
|
+
/**
|
|
90
|
+
* @description Logging + rendering-engine methods for a call. Mirrors the
|
|
91
|
+
* `Service` `logCtx` contract and exposes `modal`/`toast`/`spinner`/`router`
|
|
92
|
+
* getters wrapping the rendering engine.
|
|
93
|
+
* @param {MaybeContextualArg<C, ARGS>} args Contextual args (context at the
|
|
94
|
+
* end, or pre-args plus context).
|
|
95
|
+
* @param {METHOD} operation The operation the context is created for.
|
|
96
|
+
* @param {boolean} allowCreate Whether a context is created when none is
|
|
97
|
+
* provided.
|
|
98
|
+
* @param {Partial<FlagsOf<CONTEXT>>} overrides Optional flag overrides.
|
|
99
|
+
* @return {UserRequestLogContext<C, ARGS> | Promise<UserRequestLogContext<C, ARGS>>}
|
|
100
|
+
* The contextual surface (or a promise of it when `allowCreate` is true).
|
|
101
|
+
* @template C The decaf context the service runs under.
|
|
102
|
+
* @template ARGS The contextual argument tuple passed to the call.
|
|
103
|
+
* @template CONTEXT The context type to promote to when creating one.
|
|
104
|
+
* @template METHOD The operation the context is created for.
|
|
105
|
+
*/
|
|
106
|
+
protected logCtx<ARGS extends any[] = any[], METHOD extends MethodOrOperation = MethodOrOperation>(args: MaybeContextualArg<C, ARGS>, operation: METHOD): UserRequestLogContext<C, ARGS>;
|
|
107
|
+
protected logCtx<CONTEXT extends Context<any> = C, ARGS extends any[] = any[], METHOD extends MethodOrOperation = MethodOrOperation>(args: MaybeContextualArg<CONTEXT, ARGS>, operation: METHOD, allowCreate: false, overrides?: Partial<FlagsOf<CONTEXT>>): UserRequestLogContext<C, ARGS>;
|
|
108
|
+
protected logCtx<CONTEXT extends Context<any> = C, ARGS extends any[] = any[], METHOD extends MethodOrOperation = MethodOrOperation>(args: MaybeContextualArg<CONTEXT, ARGS>, operation: METHOD, allowCreate: true, overrides?: Partial<FlagsOf<CONTEXT>>): Promise<UserRequestLogContext<C, ARGS>>;
|
|
109
|
+
/**
|
|
110
|
+
* @description Decorates the base contextual surface with the rendering
|
|
111
|
+
* engine methods exposed as `modal`/`toast`/`spinner`/`router` bound getters.
|
|
112
|
+
* @return {UserRequestLogContext<C, ARGS>} The decorated contextual surface.
|
|
113
|
+
* @template C The decaf context the service runs under.
|
|
114
|
+
* @template ARGS The contextual argument tuple passed to the call.
|
|
115
|
+
*/
|
|
116
|
+
private wrapLogContext;
|
|
117
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module ui-decorators/user-requests/constants
|
|
3
|
+
* @summary Metadata keys for the User Request Resolution Engine.
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* @description Metadata key under which user request handlers are registered
|
|
7
|
+
* and resolved.
|
|
8
|
+
* @summary The `@userRequest(reference)` decorator stores both the handler
|
|
9
|
+
* reference and the decorating metadata under this key, and
|
|
10
|
+
* `UserRequestHandler.getHandler` / `UserRequestHandler.getMetadata` read it
|
|
11
|
+
* back. The key is scoped to the User Request Resolution Engine to avoid
|
|
12
|
+
* colliding with other reflection metadata.
|
|
13
|
+
* @const USER_REQUEST_KEY
|
|
14
|
+
* @type {string}
|
|
15
|
+
* @readonly
|
|
16
|
+
*/
|
|
17
|
+
export declare const USER_REQUEST_KEY = "user-requests.handler";
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module ui-decorators/user-requests/constants
|
|
3
|
+
* @summary Metadata keys for the User Request Resolution Engine.
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* @description Metadata key under which user request handlers are registered
|
|
7
|
+
* and resolved.
|
|
8
|
+
* @summary The `@userRequest(reference)` decorator stores both the handler
|
|
9
|
+
* reference and the decorating metadata under this key, and
|
|
10
|
+
* `UserRequestHandler.getHandler` / `UserRequestHandler.getMetadata` read it
|
|
11
|
+
* back. The key is scoped to the User Request Resolution Engine to avoid
|
|
12
|
+
* colliding with other reflection metadata.
|
|
13
|
+
* @const USER_REQUEST_KEY
|
|
14
|
+
* @type {string}
|
|
15
|
+
* @readonly
|
|
16
|
+
*/
|
|
17
|
+
export declare const USER_REQUEST_KEY = "user-requests.handler";
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module ui-decorators/user-requests/decorators
|
|
3
|
+
* @summary `@userRequest(reference)` class decorator.
|
|
4
|
+
* @description No Angular or DOM imports — safe for pure-Node (backend)
|
|
5
|
+
* bundles. Registration is metadata-based: the decorator records the handler
|
|
6
|
+
* class under `USER_REQUEST_KEY` and the static `UserRequestHandler` methods
|
|
7
|
+
* resolve and dispatch it, so no process-wide registry is involved.
|
|
8
|
+
*/
|
|
9
|
+
/**
|
|
10
|
+
* @description Registers a handler class for the given request id/type.
|
|
11
|
+
*
|
|
12
|
+
* Mirrors `core/src/migrations/decorators.ts`:
|
|
13
|
+
* `Decoration.for(KEY).define({ decorator, args }).apply()` plus
|
|
14
|
+
* `Metadata.set(USER_REQUEST_KEY, reference, original)` so the class is
|
|
15
|
+
* retrievable by id via metadata — `UserRequestHandler.getHandler(reference)`
|
|
16
|
+
* reads it back and `UserRequestHandler.handle(request, renderingEngine)`
|
|
17
|
+
* dispatches it — and a class-level `metadata(...)` payload for
|
|
18
|
+
* introspection (`UserRequestHandler.getMetadata(target)`).
|
|
19
|
+
* @param {string} reference The request id/type the handler is registered for.
|
|
20
|
+
* @return {ClassDecorator} The class decorator to apply.
|
|
21
|
+
*/
|
|
22
|
+
export declare function userRequest(reference: string): ClassDecorator;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module ui-decorators/user-requests/decorators
|
|
3
|
+
* @summary `@userRequest(reference)` class decorator.
|
|
4
|
+
* @description No Angular or DOM imports — safe for pure-Node (backend)
|
|
5
|
+
* bundles. Registration is metadata-based: the decorator records the handler
|
|
6
|
+
* class under `USER_REQUEST_KEY` and the static `UserRequestHandler` methods
|
|
7
|
+
* resolve and dispatch it, so no process-wide registry is involved.
|
|
8
|
+
*/
|
|
9
|
+
/**
|
|
10
|
+
* @description Registers a handler class for the given request id/type.
|
|
11
|
+
*
|
|
12
|
+
* Mirrors `core/src/migrations/decorators.ts`:
|
|
13
|
+
* `Decoration.for(KEY).define({ decorator, args }).apply()` plus
|
|
14
|
+
* `Metadata.set(USER_REQUEST_KEY, reference, original)` so the class is
|
|
15
|
+
* retrievable by id via metadata — `UserRequestHandler.getHandler(reference)`
|
|
16
|
+
* reads it back and `UserRequestHandler.handle(request, renderingEngine)`
|
|
17
|
+
* dispatches it — and a class-level `metadata(...)` payload for
|
|
18
|
+
* introspection (`UserRequestHandler.getMetadata(target)`).
|
|
19
|
+
* @param {string} reference The request id/type the handler is registered for.
|
|
20
|
+
* @return {ClassDecorator} The class decorator to apply.
|
|
21
|
+
*/
|
|
22
|
+
export declare function userRequest(reference: string): ClassDecorator;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module ui-decorators/user-requests/errors
|
|
3
|
+
* @summary Decaf error hierarchy for the User Request Resolution Engine.
|
|
4
|
+
*/
|
|
5
|
+
import { InternalError } from "@decaf-ts/db-decorators";
|
|
6
|
+
/**
|
|
7
|
+
* @description Error thrown when the user cancels a user request mid-resolution.
|
|
8
|
+
* Follows the decaf error hierarchy: never a raw `Error`. Compatible with the
|
|
9
|
+
* validation error signaling used by `@devcerts/decaf` UI facades.
|
|
10
|
+
* @summary Error thrown when a user request is cancelled.
|
|
11
|
+
*/
|
|
12
|
+
export declare class CancelledError extends InternalError {
|
|
13
|
+
/**
|
|
14
|
+
* @param {string | Error | unknown} msg The cancellation message.
|
|
15
|
+
* @return {CancelledError} A new `CancelledError`.
|
|
16
|
+
*/
|
|
17
|
+
constructor(msg?: string | Error | unknown);
|
|
18
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module ui-decorators/user-requests/errors
|
|
3
|
+
* @summary Decaf error hierarchy for the User Request Resolution Engine.
|
|
4
|
+
*/
|
|
5
|
+
import { InternalError } from "@decaf-ts/db-decorators";
|
|
6
|
+
/**
|
|
7
|
+
* @description Error thrown when the user cancels a user request mid-resolution.
|
|
8
|
+
* Follows the decaf error hierarchy: never a raw `Error`. Compatible with the
|
|
9
|
+
* validation error signaling used by `@devcerts/decaf` UI facades.
|
|
10
|
+
* @summary Error thrown when a user request is cancelled.
|
|
11
|
+
*/
|
|
12
|
+
export declare class CancelledError extends InternalError {
|
|
13
|
+
/**
|
|
14
|
+
* @param {string | Error | unknown} msg The cancellation message.
|
|
15
|
+
* @return {CancelledError} A new `CancelledError`.
|
|
16
|
+
*/
|
|
17
|
+
constructor(msg?: string | Error | unknown);
|
|
18
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module ui-decorators/user-requests
|
|
3
|
+
* @summary Backend binding surface for the User Request Resolution Engine.
|
|
4
|
+
* @description Framework-agnostic core of the engine: no Angular or DOM
|
|
5
|
+
* imports, safe for pure-Node (backend) bundles. Handlers are registered via
|
|
6
|
+
* `@userRequest(reference)` (metadata) and resolved/dispatched through the
|
|
7
|
+
* static `UserRequestHandler` methods; example handlers and rendering-engine
|
|
8
|
+
* mocks live only in the test tree, never under `src`. Frontend bindings live
|
|
9
|
+
* in `for-angular`.
|
|
10
|
+
*/
|
|
11
|
+
export * from "./constants.d.cts";
|
|
12
|
+
export * from "./errors.d.cts";
|
|
13
|
+
export * from "./types.d.cts";
|
|
14
|
+
export * from "./UserRequestHandler.d.cts";
|
|
15
|
+
export * from "./decorators.d.cts";
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module ui-decorators/user-requests
|
|
3
|
+
* @summary Backend binding surface for the User Request Resolution Engine.
|
|
4
|
+
* @description Framework-agnostic core of the engine: no Angular or DOM
|
|
5
|
+
* imports, safe for pure-Node (backend) bundles. Handlers are registered via
|
|
6
|
+
* `@userRequest(reference)` (metadata) and resolved/dispatched through the
|
|
7
|
+
* static `UserRequestHandler` methods; example handlers and rendering-engine
|
|
8
|
+
* mocks live only in the test tree, never under `src`. Frontend bindings live
|
|
9
|
+
* in `for-angular`.
|
|
10
|
+
*/
|
|
11
|
+
export * from "./constants.d.mts";
|
|
12
|
+
export * from "./errors.d.mts";
|
|
13
|
+
export * from "./types.d.mts";
|
|
14
|
+
export * from "./UserRequestHandler.d.mts";
|
|
15
|
+
export * from "./decorators.d.mts";
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module ui-decorators/user-requests/types
|
|
3
|
+
* @summary Framework-agnostic contracts for the User Request Resolution Engine.
|
|
4
|
+
* @description No Angular or DOM imports are allowed here so the `user-requests`
|
|
5
|
+
* entry point stays consumable from pure-Node (backend) bundles.
|
|
6
|
+
*/
|
|
7
|
+
import type { RenderingEngine } from "../ui/Rendering.d.cts";
|
|
8
|
+
/**
|
|
9
|
+
* @description A user request payload. `id` identifies the request instance,
|
|
10
|
+
* `type` is the keyed handler reference used for resolution — handlers are
|
|
11
|
+
* dispatched via `UserRequestHandler.handle(request, renderingEngine)`, which
|
|
12
|
+
* resolves the registered handler class by `request.type || request.id` — and
|
|
13
|
+
* `payload` carries optional request data.
|
|
14
|
+
* @template T The shape of the optional request data.
|
|
15
|
+
*/
|
|
16
|
+
export interface UserRequest<T = unknown> {
|
|
17
|
+
id: string;
|
|
18
|
+
type: string;
|
|
19
|
+
payload?: T;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* @description The rendering-engine surface a user request handler needs.
|
|
23
|
+
* Exposes exactly the four real `RenderingEngine` methods a handler drives
|
|
24
|
+
* (modal, toast, spinner and router); no duplicated rendering types.
|
|
25
|
+
* @summary The four real `RenderingEngine` methods handed to handlers.
|
|
26
|
+
*/
|
|
27
|
+
export type RenderingFacade = Pick<RenderingEngine, "getModal" | "getToast" | "getSpinner" | "router">;
|
|
28
|
+
/**
|
|
29
|
+
* @description Metadata recorded by `@userRequest(reference)` on a handler
|
|
30
|
+
* class and read back via `UserRequestHandler.getMetadata(target)`. `reference`
|
|
31
|
+
* is the request id/type the handler is registered for.
|
|
32
|
+
* @summary Metadata recorded on a `@userRequest`-decorated handler class.
|
|
33
|
+
*/
|
|
34
|
+
export interface UserRequestHandlerMetadata {
|
|
35
|
+
reference: string;
|
|
36
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module ui-decorators/user-requests/types
|
|
3
|
+
* @summary Framework-agnostic contracts for the User Request Resolution Engine.
|
|
4
|
+
* @description No Angular or DOM imports are allowed here so the `user-requests`
|
|
5
|
+
* entry point stays consumable from pure-Node (backend) bundles.
|
|
6
|
+
*/
|
|
7
|
+
import type { RenderingEngine } from "../ui/Rendering.d.mts";
|
|
8
|
+
/**
|
|
9
|
+
* @description A user request payload. `id` identifies the request instance,
|
|
10
|
+
* `type` is the keyed handler reference used for resolution — handlers are
|
|
11
|
+
* dispatched via `UserRequestHandler.handle(request, renderingEngine)`, which
|
|
12
|
+
* resolves the registered handler class by `request.type || request.id` — and
|
|
13
|
+
* `payload` carries optional request data.
|
|
14
|
+
* @template T The shape of the optional request data.
|
|
15
|
+
*/
|
|
16
|
+
export interface UserRequest<T = unknown> {
|
|
17
|
+
id: string;
|
|
18
|
+
type: string;
|
|
19
|
+
payload?: T;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* @description The rendering-engine surface a user request handler needs.
|
|
23
|
+
* Exposes exactly the four real `RenderingEngine` methods a handler drives
|
|
24
|
+
* (modal, toast, spinner and router); no duplicated rendering types.
|
|
25
|
+
* @summary The four real `RenderingEngine` methods handed to handlers.
|
|
26
|
+
*/
|
|
27
|
+
export type RenderingFacade = Pick<RenderingEngine, "getModal" | "getToast" | "getSpinner" | "router">;
|
|
28
|
+
/**
|
|
29
|
+
* @description Metadata recorded by `@userRequest(reference)` on a handler
|
|
30
|
+
* class and read back via `UserRequestHandler.getMetadata(target)`. `reference`
|
|
31
|
+
* is the request id/type the handler is registered for.
|
|
32
|
+
* @summary Metadata recorded on a `@userRequest`-decorated handler class.
|
|
33
|
+
*/
|
|
34
|
+
export interface UserRequestHandlerMetadata {
|
|
35
|
+
reference: string;
|
|
36
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@decaf-ts/ui-decorators",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.19.0",
|
|
4
4
|
"description": "Extension of decorator validation to ui elements to allow for web integration",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
@@ -25,6 +25,17 @@
|
|
|
25
25
|
"default": "./lib/cjs/graph/index.cjs"
|
|
26
26
|
},
|
|
27
27
|
"default": "./lib/esm/graph/index.js"
|
|
28
|
+
},
|
|
29
|
+
"./user-requests": {
|
|
30
|
+
"import": {
|
|
31
|
+
"types": "./lib/types/user-requests/index.d.mts",
|
|
32
|
+
"default": "./lib/esm/user-requests/index.js"
|
|
33
|
+
},
|
|
34
|
+
"require": {
|
|
35
|
+
"types": "./lib/types/user-requests/index.d.cts",
|
|
36
|
+
"default": "./lib/cjs/user-requests/index.cjs"
|
|
37
|
+
},
|
|
38
|
+
"default": "./lib/esm/user-requests/index.js"
|
|
28
39
|
}
|
|
29
40
|
},
|
|
30
41
|
"types": "./lib/types/index.d.mts",
|
|
@@ -47,7 +58,7 @@
|
|
|
47
58
|
"lint": "eslint .",
|
|
48
59
|
"lint-fix": "eslint --fix .",
|
|
49
60
|
"prepare-pr": "npm run lint-fix && npm run build:prod && npm run coverage && npm run docs",
|
|
50
|
-
"prepare-release": "npm run lint-fix && npm run build:prod && npm run coverage
|
|
61
|
+
"prepare-release": "npm run lint-fix && npm run build:prod && npm run coverage",
|
|
51
62
|
"release": "./bin/tag-release.sh",
|
|
52
63
|
"clean-publish": "npx clean-publish",
|
|
53
64
|
"drawings": "for FILE in workdocs/drawings/*.drawio; do echo \"converting $FILE to image...\" && docker run --rm -v $(pwd):/data rlespinasse/drawio-export --format png $FILE; done && cp -rf workdocs/drawings/export/* workdocs/resources/",
|
|
@@ -108,9 +119,12 @@
|
|
|
108
119
|
"@types/jest": "^30.0.0"
|
|
109
120
|
},
|
|
110
121
|
"dependencies": {
|
|
122
|
+
"@decaf-ts/core": "latest",
|
|
111
123
|
"@decaf-ts/db-decorators": "latest",
|
|
112
124
|
"@decaf-ts/decoration": "latest",
|
|
113
|
-
"@decaf-ts/decorator-validation": "latest"
|
|
125
|
+
"@decaf-ts/decorator-validation": "latest",
|
|
126
|
+
"better-docs": "^2.7.3",
|
|
127
|
+
"taffydb": "^2.7.3"
|
|
114
128
|
},
|
|
115
129
|
"main": "./lib/cjs/index.cjs",
|
|
116
130
|
"module": "./lib/esm/index.js",
|
|
@@ -123,5 +137,9 @@
|
|
|
123
137
|
"./lib/cjs/graph/overrides/index.cjs",
|
|
124
138
|
"./lib/cjs/graph/overrides/overrides.cjs",
|
|
125
139
|
"./lib/cjs/model/overrides.cjs"
|
|
126
|
-
]
|
|
140
|
+
],
|
|
141
|
+
"overrides": {
|
|
142
|
+
"test-exclude": "^7.0.2",
|
|
143
|
+
"brace-expansion": "^5.0.8"
|
|
144
|
+
}
|
|
127
145
|
}
|