@cosmicdrift/kumiko-types 0.263.0 → 0.264.1
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/package.json +1 -1
- package/src/define-handler.ts +1 -0
- package/src/feature.ts +28 -6
- package/src/handlers.ts +7 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cosmicdrift/kumiko-types",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.264.1",
|
|
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>",
|
package/src/define-handler.ts
CHANGED
|
@@ -97,6 +97,7 @@ export type QueryHandlerDefinition<
|
|
|
97
97
|
readonly description?: string;
|
|
98
98
|
readonly agent?: AgentHandlerHints;
|
|
99
99
|
readonly rateLimit?: RateLimitOption;
|
|
100
|
+
readonly escapeHatch?: EscapeHatchDeclaration;
|
|
100
101
|
readonly handler: (
|
|
101
102
|
query: QueryEvent<z.infer<TSchema>>,
|
|
102
103
|
context: HandlerContext<TMap>,
|
package/src/feature.ts
CHANGED
|
@@ -477,6 +477,7 @@ export type FeatureRegistrar<TFeature extends string = string> = {
|
|
|
477
477
|
outputSchema?: ZodType;
|
|
478
478
|
description?: string;
|
|
479
479
|
agent?: AgentHandlerHints;
|
|
480
|
+
escapeHatch?: EscapeHatchDeclaration;
|
|
480
481
|
},
|
|
481
482
|
): HandlerRef;
|
|
482
483
|
|
|
@@ -500,7 +501,13 @@ export type FeatureRegistrar<TFeature extends string = string> = {
|
|
|
500
501
|
): void;
|
|
501
502
|
|
|
502
503
|
hook(type: "validation", target: RefOrRefs, fn: ValidationHookFn): void;
|
|
503
|
-
hook(
|
|
504
|
+
// escapeHatch grants this hook (not the handler) SYSTEM identity-switches — see system-identity-switch.ts.
|
|
505
|
+
hook(
|
|
506
|
+
type: "preSave",
|
|
507
|
+
target: RefOrRefs,
|
|
508
|
+
fn: PreSaveHookFn,
|
|
509
|
+
options?: { escapeHatch?: EscapeHatchDeclaration },
|
|
510
|
+
): void;
|
|
504
511
|
// postSave/preDelete/postDelete/postQuery accept `{ allOf: entityRef }` —
|
|
505
512
|
// fires for every write/query handler of that entity, replacing the old
|
|
506
513
|
// r.entityHook(type, entity, fn). postQuery's entity-wide form fires for
|
|
@@ -511,19 +518,34 @@ export type FeatureRegistrar<TFeature extends string = string> = {
|
|
|
511
518
|
type: "postSave",
|
|
512
519
|
target: HookTarget,
|
|
513
520
|
fn: PostSaveHookFn,
|
|
514
|
-
options?: { phase?: HookPhase },
|
|
521
|
+
options?: { phase?: HookPhase; escapeHatch?: EscapeHatchDeclaration },
|
|
515
522
|
): void;
|
|
516
523
|
// preDelete always runs in-transaction (it guards the delete — there is no
|
|
517
524
|
// meaningful "after" for a pre-hook). No phase option.
|
|
518
|
-
hook(
|
|
525
|
+
hook(
|
|
526
|
+
type: "preDelete",
|
|
527
|
+
target: HookTarget,
|
|
528
|
+
fn: PreDeleteHookFn,
|
|
529
|
+
options?: { escapeHatch?: EscapeHatchDeclaration },
|
|
530
|
+
): void;
|
|
519
531
|
hook(
|
|
520
532
|
type: "postDelete",
|
|
521
533
|
target: HookTarget,
|
|
522
534
|
fn: PostDeleteHookFn,
|
|
523
|
-
options?: { phase?: HookPhase },
|
|
535
|
+
options?: { phase?: HookPhase; escapeHatch?: EscapeHatchDeclaration },
|
|
536
|
+
): void;
|
|
537
|
+
hook(
|
|
538
|
+
type: "preQuery",
|
|
539
|
+
target: RefOrRefs,
|
|
540
|
+
fn: PreQueryHookFn,
|
|
541
|
+
options?: { escapeHatch?: EscapeHatchDeclaration },
|
|
542
|
+
): void;
|
|
543
|
+
hook(
|
|
544
|
+
type: "postQuery",
|
|
545
|
+
target: HookTarget,
|
|
546
|
+
fn: PostQueryHookFn,
|
|
547
|
+
options?: { escapeHatch?: EscapeHatchDeclaration },
|
|
524
548
|
): void;
|
|
525
|
-
hook(type: "preQuery", target: RefOrRefs, fn: PreQueryHookFn): void;
|
|
526
|
-
hook(type: "postQuery", target: HookTarget, fn: PostQueryHookFn): void;
|
|
527
549
|
|
|
528
550
|
// F3 — Search-Payload-Extension: contributor function adds flat fields to
|
|
529
551
|
// an entity's search-index document. Fires synchronously during
|
package/src/handlers.ts
CHANGED
|
@@ -378,7 +378,9 @@ export type AppContext = SharedContextFields & {
|
|
|
378
378
|
// sharing the active tx + afterCommit queue. Field-access filters apply.
|
|
379
379
|
// ctx.queryAs / ctx.writeAs switch identity (e.g. SYSTEM for privileged
|
|
380
380
|
// lookups like "find user by email for auth" — system reads aren't filtered
|
|
381
|
-
// by field-access read rules).
|
|
381
|
+
// by field-access read rules). SYSTEM as the target is gated: reachable
|
|
382
|
+
// only from an r.systemScope() feature, a job, or a handler/hook that
|
|
383
|
+
// declared { escapeHatch: { reason } } (system-identity-switch.ts).
|
|
382
384
|
//
|
|
383
385
|
// The design: handlers are the contract between features. Feature A requires
|
|
384
386
|
// Feature B and talks to it through B's registered handlers — never through
|
|
@@ -1063,6 +1065,10 @@ export type QueryHandlerDef = {
|
|
|
1063
1065
|
* `header`/`metrics`, dashboard `valueField`/`subField`/etc.) rather
|
|
1064
1066
|
* than requiring it retroactively. See fw#2493. */
|
|
1065
1067
|
readonly outputSchema?: ZodType;
|
|
1068
|
+
// Query handlers can't reach db.global() (that gate is write-only), but
|
|
1069
|
+
// they can still switch identity to SYSTEM via ctx.queryAs — this opts
|
|
1070
|
+
// in, same contract as WriteHandlerDef.escapeHatch.
|
|
1071
|
+
readonly escapeHatch?: EscapeHatchDeclaration;
|
|
1066
1072
|
};
|
|
1067
1073
|
|
|
1068
1074
|
export type StreamHandlerDef = {
|