@cosmicdrift/kumiko-types 0.262.0 → 0.264.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cosmicdrift/kumiko-types",
3
- "version": "0.262.0",
3
+ "version": "0.264.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>",
@@ -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(type: "preSave", target: RefOrRefs, fn: PreSaveHookFn): void;
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(type: "preDelete", target: HookTarget, fn: PreDeleteHookFn): void;
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 = {
package/src/screen.ts CHANGED
@@ -995,6 +995,10 @@ export type EntityEditScreenDefinition = {
995
995
  readonly detailFor?: string;
996
996
  readonly description?: string;
997
997
  readonly agent?: AgentHandlerHints;
998
+ /** Derived by buildAppSchema from the navigate `params` targeting this
999
+ * screen — the only URL query keys the create form prefills. An authored
1000
+ * value is overwritten. */
1001
+ readonly urlPrefillFields?: readonly string[];
998
1002
  readonly entity: string;
999
1003
  readonly layout: EditLayout;
1000
1004
  /** Optionaler i18n-Key (oder Roh-String) für den Submit-Button. Default
@@ -1088,6 +1092,8 @@ export type ActionFormScreenDefinition = {
1088
1092
  readonly detailFor?: string;
1089
1093
  readonly description?: string;
1090
1094
  readonly agent?: AgentHandlerHints;
1095
+ /** Derived by buildAppSchema — see EntityEditScreenDefinition.urlPrefillFields. */
1096
+ readonly urlPrefillFields?: readonly string[];
1091
1097
  /** Write-Handler-QN der bei Submit gerufen wird. Form-Object landet
1092
1098
  * 1:1 als payload — Handler-Schema (Zod) validiert weiter. */
1093
1099
  readonly handler: string;
@@ -1217,6 +1223,8 @@ export type SecretMintScreenDefinition = {
1217
1223
  readonly detailFor?: string;
1218
1224
  readonly description?: string;
1219
1225
  readonly agent?: AgentHandlerHints;
1226
+ /** Derived by buildAppSchema — see EntityEditScreenDefinition.urlPrefillFields. */
1227
+ readonly urlPrefillFields?: readonly string[];
1220
1228
  /** Write-handler QN dispatched on submit. */
1221
1229
  readonly handler: string;
1222
1230
  readonly fields: Readonly<Record<string, FieldDefinition>>;