@cosmicdrift/kumiko-types 0.347.0 → 0.348.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/define-handler.d.ts +3 -1
- package/dist/handlers.d.ts +11 -0
- package/package.json +1 -1
package/dist/define-handler.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type * as z from "zod";
|
|
2
2
|
import type { ZodType } from "zod";
|
|
3
3
|
import type { KumikoEventTypeMap } from "./event-type-map.js";
|
|
4
|
-
import type { AccessRule, AgentHandlerHints, EscapeHatchDeclaration, HandlerContext, PayloadRateLimitOption, QueryEvent, RateLimitDeclaration, WriteEvent, WriteResult } from "./handlers.js";
|
|
4
|
+
import type { AccessRule, AgentHandlerHints, EscapeHatchDeclaration, HandlerContext, PayloadRateLimitOption, PreTransactionReservation, QueryEvent, RateLimitDeclaration, WriteEvent, WriteResult } from "./handlers.js";
|
|
5
5
|
import type { PipelineDef } from "./step.js";
|
|
6
6
|
export type WriteHandlerDefinition<TName extends string = string, TSchema extends ZodType = ZodType, TData = unknown, TMap extends object = KumikoEventTypeMap> = {
|
|
7
7
|
readonly name: TName;
|
|
@@ -13,6 +13,7 @@ export type WriteHandlerDefinition<TName extends string = string, TSchema extend
|
|
|
13
13
|
readonly rateLimit?: RateLimitDeclaration;
|
|
14
14
|
readonly additionalRateLimits?: readonly PayloadRateLimitOption[];
|
|
15
15
|
readonly escapeHatch?: EscapeHatchDeclaration;
|
|
16
|
+
readonly reserveBeforeTransaction?: PreTransactionReservation;
|
|
16
17
|
readonly tenantlessAnonymous?: boolean;
|
|
17
18
|
readonly handler: (event: WriteEvent<z.infer<TSchema>>, context: HandlerContext<TMap>) => Promise<WriteResult<TData>>;
|
|
18
19
|
readonly perform?: PipelineDef<z.infer<TSchema>, TData>;
|
|
@@ -27,6 +28,7 @@ export type WriteHandlerInput<TName extends string = string, TSchema extends Zod
|
|
|
27
28
|
readonly rateLimit?: RateLimitDeclaration;
|
|
28
29
|
readonly additionalRateLimits?: readonly PayloadRateLimitOption[];
|
|
29
30
|
readonly escapeHatch?: EscapeHatchDeclaration;
|
|
31
|
+
readonly reserveBeforeTransaction?: PreTransactionReservation;
|
|
30
32
|
readonly tenantlessAnonymous?: boolean;
|
|
31
33
|
} & ({
|
|
32
34
|
readonly handler: (event: WriteEvent<z.infer<TSchema>>, context: HandlerContext<TMap>) => Promise<WriteResult<TData>>;
|
package/dist/handlers.d.ts
CHANGED
|
@@ -503,6 +503,14 @@ export type AgentExposure = {
|
|
|
503
503
|
readonly expose: boolean;
|
|
504
504
|
readonly risk: AgentRisk;
|
|
505
505
|
};
|
|
506
|
+
/** Undoes a reservation made before the handler transaction. */
|
|
507
|
+
export type ReservationRelease = () => Promise<void>;
|
|
508
|
+
/** Runs in the dispatcher after access and schema checks but before the
|
|
509
|
+
* handler transaction opens, so it must commit its own short write instead
|
|
510
|
+
* of holding a second connection while the transaction is open. The returned
|
|
511
|
+
* release runs when the transaction does not commit (failure result, throw,
|
|
512
|
+
* rollback, failed commit). Throwing a KumikoError rejects the write. */
|
|
513
|
+
export type PreTransactionReservation = (event: WriteEvent, ctx: HandlerContext) => Promise<ReservationRelease | undefined>;
|
|
506
514
|
export type WriteHandlerDef = {
|
|
507
515
|
readonly name: string;
|
|
508
516
|
readonly schema: ZodType;
|
|
@@ -516,6 +524,9 @@ export type WriteHandlerDef = {
|
|
|
516
524
|
* `rateLimit`; anonymous handlers still need an ip-keyed `rateLimit`. */
|
|
517
525
|
readonly additionalRateLimits?: readonly PayloadRateLimitOption[];
|
|
518
526
|
readonly escapeHatch?: EscapeHatchDeclaration;
|
|
527
|
+
/** Reserves before the handler transaction opens. Reached through a nested ctx.write the
|
|
528
|
+
* reservation cannot run, so the dispatcher rejects it unless the top-level batch reserved it. */
|
|
529
|
+
readonly reserveBeforeTransaction?: PreTransactionReservation;
|
|
519
530
|
/** Lets an anonymous `POST /api/write` for this handler proceed under
|
|
520
531
|
* SYSTEM_TENANT_ID when the host resolves no tenant. Boot requires
|
|
521
532
|
* `access.roles: ["anonymous"]` and a real `rateLimit`. */
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cosmicdrift/kumiko-types",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.348.0",
|
|
4
4
|
"description": "Framework-Type-Definitions für Kumiko — FeatureDefinition, BootCheck-Types und die reinen Engine-Types. Erlaubt Downstream-Konsumenten, gegen die Type-Contracts zu bauen, ohne das ganze Framework-Package zu importieren. Enthaelt keine identitaets-sensitiven Runtime-Werte mehr (Error-Klassen leben seit #1629 in kumiko-framework, Brand-Symbole nutzen Symbol.for) und ist deshalb eine plain dependency, keine peerDependency.",
|
|
5
5
|
"license": "BUSL-1.1",
|
|
6
6
|
"author": "Marc Frost <marc@cosmicdriftgamestudio.com>",
|