@cosmicdrift/kumiko-types 0.268.0 → 0.269.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 +1 -1
- package/src/define-handler.ts +4 -0
- package/src/feature.ts +6 -2
- package/src/handlers.ts +7 -2
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cosmicdrift/kumiko-types",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.269.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>",
|
package/src/define-handler.ts
CHANGED
|
@@ -126,6 +126,10 @@ export type StreamHandlerDefinition<
|
|
|
126
126
|
readonly schema: TSchema;
|
|
127
127
|
readonly access: AccessRule;
|
|
128
128
|
readonly rateLimit?: RateLimitOption;
|
|
129
|
+
// Stream handlers can't reach db.global() (that gate is write-only), but
|
|
130
|
+
// they can still switch identity to SYSTEM via ctx.queryAs — this opts
|
|
131
|
+
// in, same contract as WriteHandlerDefinition.escapeHatch.
|
|
132
|
+
readonly escapeHatch?: EscapeHatchDeclaration;
|
|
129
133
|
readonly handler: (
|
|
130
134
|
query: QueryEvent<z.infer<TSchema>>,
|
|
131
135
|
context: HandlerContext<TMap>,
|
package/src/feature.ts
CHANGED
|
@@ -488,7 +488,11 @@ export type FeatureRegistrar<TFeature extends string = string> = {
|
|
|
488
488
|
name: string,
|
|
489
489
|
schema: TSchema,
|
|
490
490
|
handler: StreamHandlerFn<z.infer<TSchema>>,
|
|
491
|
-
options: {
|
|
491
|
+
options: {
|
|
492
|
+
access: AccessRule;
|
|
493
|
+
rateLimit?: RateLimitOption;
|
|
494
|
+
escapeHatch?: EscapeHatchDeclaration;
|
|
495
|
+
},
|
|
492
496
|
): HandlerRef;
|
|
493
497
|
|
|
494
498
|
relation(entity: NameOrRef, relationName: string, definition: RelationDefinition): void;
|
|
@@ -501,7 +505,7 @@ export type FeatureRegistrar<TFeature extends string = string> = {
|
|
|
501
505
|
): void;
|
|
502
506
|
|
|
503
507
|
hook(type: "validation", target: RefOrRefs, fn: ValidationHookFn): void;
|
|
504
|
-
// escapeHatch grants this hook (not the handler)
|
|
508
|
+
// escapeHatch grants this hook (not the handler) identity-switches beyond its caller — see system-identity-switch.ts.
|
|
505
509
|
hook(
|
|
506
510
|
type: "preSave",
|
|
507
511
|
target: RefOrRefs,
|
package/src/handlers.ts
CHANGED
|
@@ -415,8 +415,9 @@ export type AppContext = SharedContextFields & {
|
|
|
415
415
|
// sharing the active tx + afterCommit queue. Field-access filters apply.
|
|
416
416
|
// ctx.queryAs / ctx.writeAs switch identity (e.g. SYSTEM for privileged
|
|
417
417
|
// lookups like "find user by email for auth" — system reads aren't filtered
|
|
418
|
-
// by field-access read rules).
|
|
419
|
-
// only from an r.systemScope()
|
|
418
|
+
// by field-access read rules). Any target other than the caller itself (or
|
|
419
|
+
// a subset of its roles) is gated: reachable only from an r.systemScope()
|
|
420
|
+
// feature, a job, or a handler/hook that
|
|
420
421
|
// declared { escapeHatch: { reason } } (system-identity-switch.ts).
|
|
421
422
|
//
|
|
422
423
|
// The design: handlers are the contract between features. Feature A requires
|
|
@@ -1128,4 +1129,8 @@ export type StreamHandlerDef = {
|
|
|
1128
1129
|
readonly handler: StreamHandlerFn;
|
|
1129
1130
|
readonly access: AccessRule;
|
|
1130
1131
|
readonly rateLimit?: RateLimitOption;
|
|
1132
|
+
// Stream handlers can't reach db.global() (that gate is write-only), but
|
|
1133
|
+
// they can still switch identity to SYSTEM via ctx.queryAs — this opts
|
|
1134
|
+
// in, same contract as WriteHandlerDef.escapeHatch.
|
|
1135
|
+
readonly escapeHatch?: EscapeHatchDeclaration;
|
|
1131
1136
|
};
|