@devflow-tools/database 0.18.1 → 0.18.3

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/dist/database.js +22 -0
  2. package/package.json +2 -2
package/dist/database.js CHANGED
@@ -3869,6 +3869,28 @@ class DevFlowDatabase {
3869
3869
  }
3870
3870
  appendTaskAggregate(input) {
3871
3871
  return this.db.transaction(() => {
3872
+ const eventIdentity = input.event.identity;
3873
+ const snapshotIdentity = input.snapshot.identity;
3874
+ if (input.event.schemaVersion !== 'task-aggregate-event.v1') {
3875
+ throw new Error('TASK_AGGREGATE_EVENT_SCHEMA_UNSUPPORTED');
3876
+ }
3877
+ if (input.snapshot.schemaVersion !== 'task-runtime-snapshot.v2') {
3878
+ throw new Error('TASK_AGGREGATE_SNAPSHOT_SCHEMA_UNSUPPORTED');
3879
+ }
3880
+ if (input.event.revision !== input.snapshot.revision
3881
+ || (input.definition && input.event.revision !== input.definition.revision)) {
3882
+ throw new Error('TASK_AGGREGATE_REVISION_MISMATCH');
3883
+ }
3884
+ if ((0, task_runtime_1.stableTaskRuntimeJson)(eventIdentity) !== (0, task_runtime_1.stableTaskRuntimeJson)(snapshotIdentity)) {
3885
+ throw new Error('TASK_AGGREGATE_IDENTITY_MISMATCH');
3886
+ }
3887
+ const { snapshotHash, ...snapshotBody } = input.snapshot;
3888
+ if (!snapshotHash || (0, task_runtime_1.stableTaskRuntimeHash)(snapshotBody) !== snapshotHash) {
3889
+ throw new Error('TASK_AGGREGATE_SNAPSHOT_HASH_MISMATCH');
3890
+ }
3891
+ if (input.definition && input.snapshot.taskDefinitionHash !== input.definition.definitionHash) {
3892
+ throw new Error('TASK_AGGREGATE_DEFINITION_MISMATCH');
3893
+ }
3872
3894
  const existingByKey = this.db.prepare(`
3873
3895
  SELECT event_json FROM devflow_task_aggregate_events_v2 WHERE idempotency_key = ?
3874
3896
  `).get(input.event.idempotencyKey);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@devflow-tools/database",
3
- "version": "0.18.1",
3
+ "version": "0.18.3",
4
4
  "description": "SQLite persistence primitives shared by DevFlow runtime packages.",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -12,7 +12,7 @@
12
12
  "test": "vitest run"
13
13
  },
14
14
  "dependencies": {
15
- "@devflow-tools/sdk": "0.18.1"
15
+ "@devflow-tools/sdk": "0.18.3"
16
16
  },
17
17
  "devDependencies": {
18
18
  "@types/node": "^22.15.0",