@dudousxd/nestjs-durable-store-prisma 0.25.0 → 0.27.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": "@dudousxd/nestjs-durable-store-prisma",
3
- "version": "0.25.0",
3
+ "version": "0.27.0",
4
4
  "description": "Prisma adapter for the nestjs-durable StateStore",
5
5
  "license": "MIT",
6
6
  "author": "Davide Carvalho",
@@ -37,8 +37,8 @@
37
37
  "prisma": "6.19.3",
38
38
  "tsup": "8.3.5",
39
39
  "typescript": "5.9.3",
40
- "@dudousxd/nestjs-durable-core": "^0.87.0",
41
- "@dudousxd/nestjs-durable-testing": "^0.24.0"
40
+ "@dudousxd/nestjs-durable-core": "^0.90.0",
41
+ "@dudousxd/nestjs-durable-testing": "^0.26.0"
42
42
  },
43
43
  "module": "./dist/index.js",
44
44
  "exports": {
@@ -43,6 +43,14 @@ model DurableWorkflowRun {
43
43
  // column existed, so it stays NULL and reads back as `undefined` = "unknown". A real-looking
44
44
  // default would be indistinguishable from a genuine registration in the dashboard facet.
45
45
  origin String? @map("origin")
46
+ // The CUSTOMER (tenancy) this run belongs to — not the worker-pool `namespace`. Nullable, no
47
+ // default: NULL = no tenant, which is every run while tenancy is off. Existing deployment:
48
+ // ALTER TABLE durable_workflow_runs ADD COLUMN tenant_id TEXT;
49
+ // ALTER TABLE durable_workflow_runs ADD COLUMN tenant_kind TEXT;
50
+ // CREATE INDEX durable_workflow_runs_tenant_idx ON durable_workflow_runs (tenant_id, created_at);
51
+ // (Prisma Migrate generates exactly this from the fields; use VARCHAR(191) on MySQL.)
52
+ tenantId String? @map("tenant_id")
53
+ tenantKind String? @map("tenant_kind")
46
54
  createdAt DateTime @map("created_at")
47
55
  updatedAt DateTime @map("updated_at")
48
56
 
@@ -61,6 +69,8 @@ model DurableWorkflowRun {
61
69
  // swap from dropping and rebuilding it. The two indexes above already agree by accident — Prisma's
62
70
  // derived names happen to be the ones MikroORM declares.
63
71
  @@index([namespace, status, createdAt], map: "durable_workflow_runs_namespace_status_idx")
72
+ // App-facing reads with tenancy on: `tenant_id = ? ORDER BY created_at DESC`.
73
+ @@index([tenantId, createdAt], map: "durable_workflow_runs_tenant_idx")
64
74
  @@map("durable_workflow_runs")
65
75
  }
66
76
 
@@ -142,6 +152,19 @@ model DurableBufferedEvent {
142
152
  @@map("durable_buffered_events")
143
153
  }
144
154
 
155
+ // Signal dedupe ids (`engine.signal(token, payload, { id })`) — only needed if you send signals with
156
+ // an `id`. One row per (token, signalId), deduplicating until `expiresAt` (epoch ms as a BigInt).
157
+ // Expired rows are ignored by `claimSignalId` and deleted by `engine.sweepExpiredSignalIds()`.
158
+ model DurableSignalId {
159
+ token String
160
+ signalId String @map("signal_id")
161
+ expiresAt BigInt @map("expires_at")
162
+
163
+ @@id([token, signalId])
164
+ @@index([expiresAt], map: "durable_signal_ids_expires_at_idx")
165
+ @@map("durable_signal_ids")
166
+ }
167
+
145
168
  // Persisted schedules (`engine.schedules`) — only needed if you use them. `spec`/`state` are
146
169
  // engine-owned JSON documents; `nextFireAt` is epoch ms as a BigInt (exact, so the compare-and-set in
147
170
  // `updateSchedule` can't be defeated by a timestamp's precision).
@@ -154,10 +177,14 @@ model DurableSchedule {
154
177
  tags Json?
155
178
  spec Json
156
179
  state Json
180
+ // The customer the schedule (and every run it starts) belongs to. NULL = none.
181
+ tenantId String? @map("tenant_id")
182
+ tenantKind String? @map("tenant_kind")
157
183
  createdAt DateTime @map("created_at")
158
184
  updatedAt DateTime @map("updated_at")
159
185
 
160
186
  // The poll's "due by T" scan: `paused = false AND next_fire_at <= T ORDER BY next_fire_at`.
161
187
  @@index([paused, nextFireAt], map: "durable_schedules_due_idx")
188
+ @@index([tenantId], map: "durable_schedules_tenant_idx")
162
189
  @@map("durable_schedules")
163
190
  }