Skip to content

Commit b74b280

Browse files
Enforce documented history payload keys
Use documented history payload fixtures. Guard history payload wire-format keys.
1 parent 475dfca commit b74b280

8 files changed

Lines changed: 741 additions & 14 deletions

src/V2/Models/WorkflowHistoryEvent.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
use Illuminate\Database\Eloquent\Relations\BelongsTo;
1111
use Workflow\V2\Enums\HistoryEventType;
1212
use Workflow\V2\Support\ConfiguredV2Models;
13+
use Workflow\V2\Support\HistoryEventPayloadContract;
1314

1415
class WorkflowHistoryEvent extends Model
1516
{
@@ -59,6 +60,7 @@ public static function record(
5960
$taskId = $taskModel?->id ?? (is_string($task) ? $task : null);
6061
$commandId = $commandModel?->id ?? (is_string($command) ? $command : null);
6162
$sequence = $run->last_history_sequence + 1;
63+
HistoryEventPayloadContract::assertKnownPayloadKeys($eventType, $payload);
6264

6365
/** @var self $event */
6466
$event = self::query()->create([

src/V2/Models/WorkflowScheduleHistoryEvent.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
use Illuminate\Database\UniqueConstraintViolationException;
1212
use Workflow\V2\Enums\HistoryEventType;
1313
use Workflow\V2\Support\ConfiguredV2Models;
14+
use Workflow\V2\Support\HistoryEventPayloadContract;
1415

1516
class WorkflowScheduleHistoryEvent extends Model
1617
{
@@ -56,6 +57,8 @@ public static function record(
5657
HistoryEventType $eventType,
5758
array $payload = [],
5859
): self {
60+
HistoryEventPayloadContract::assertKnownPayloadKeys($eventType, $payload);
61+
5962
$snapshot = self::snapshotPayload($schedule, $payload);
6063
$workflowInstanceId = self::stringValue($payload['workflow_instance_id'] ?? null);
6164
$workflowRunId = self::stringValue($payload['workflow_run_id'] ?? null);

0 commit comments

Comments
 (0)