@cosmicdrift/kumiko-types 0.312.0 → 0.313.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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/handlers.ts +17 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cosmicdrift/kumiko-types",
3
- "version": "0.312.0",
3
+ "version": "0.313.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/handlers.ts CHANGED
@@ -4,7 +4,7 @@ import type { ConfigAccessor, ConfigAccessorFactory, ConfigResolver } from "./co
4
4
  import type { DbConnection } from "./db-connection";
5
5
  import type { DerivativesContext } from "./derivatives-types";
6
6
  import type { EntityCache } from "./entity-cache";
7
- import type { WriteOrigin } from "./event-store-types";
7
+ import type { EventMetadata, WriteOrigin } from "./event-store-types";
8
8
  import type { KumikoEventTypeMap } from "./event-type-map";
9
9
  import type { FileContext } from "./file-handle-types";
10
10
  import type { FileProviderResolver } from "./file-provider-resolver-types";
@@ -245,12 +245,21 @@ import type { UncheckedSystemDb } from "./tenant-db-types";
245
245
  // The framework resolves the member internally, so no hand-built SessionUser reaches app code.
246
246
  export type MemberReader = (userId: string, qn: string, payload: unknown) => Promise<unknown>;
247
247
 
248
+ // The stored event that made an r.job trigger fire, carried through so the
249
+ // job handler can key an idempotency check on it (at-least-once delivery via
250
+ // the job-trigger event consumer, see pipeline/system-hooks.ts).
251
+ export type JobTriggerEvent = {
252
+ readonly id: string;
253
+ readonly headers: NonNullable<EventMetadata["headers"]>;
254
+ };
255
+
248
256
  // Minimal interface for job event triggers (framework-owned, concrete type in jobs/)
249
257
  export type JobRunnerRef = {
250
258
  handleEvent(
251
259
  eventName: string,
252
260
  payload: Record<string, unknown>,
253
261
  user?: SessionUser,
262
+ triggerEvent?: JobTriggerEvent,
254
263
  ): Promise<void>;
255
264
  };
256
265
 
@@ -754,6 +763,13 @@ export type JobContext = SharedContextFields & {
754
763
  // Multi-trigger jobs (`on: [...]`) use this to tell which trigger fired —
755
764
  // undefined for cron/manual jobs. Mirrors AppContext.triggerName.
756
765
  readonly triggerName?: string;
766
+ // The stored event that triggered this job run, when reached via the
767
+ // job-trigger event consumer (async, at-least-once). Undefined for
768
+ // cron/manual jobs and for the synchronous handler-QN dispatch path, which
769
+ // has no stored event to hand over. Use triggerEvent.id (or a header) as
770
+ // an idempotency key — at-least-once delivery can run the same trigger
771
+ // more than once.
772
+ readonly triggerEvent?: JobTriggerEvent;
757
773
  // Fallback tenant/user when systemUser doesn't carry it (tenant-less cron
758
774
  // jobs). Mirrors AppContext._tenantId/_userId — see the tenant-scoping
759
775
  // footgun above.