@dudousxd/nestjs-durable-store-drizzle 0.26.0 → 0.28.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/dist/pg/index.cjs CHANGED
@@ -107,6 +107,8 @@ var DURABLE_PG_DDL = [
107
107
  "priority" integer,
108
108
  "namespace" text DEFAULT 'default' NOT NULL,
109
109
  "origin" text,
110
+ "tenant_id" text,
111
+ "tenant_kind" text,
110
112
  "created_at" timestamp with time zone NOT NULL,
111
113
  "updated_at" timestamp with time zone NOT NULL
112
114
  )`,
@@ -169,9 +171,16 @@ var DURABLE_PG_DDL = [
169
171
  "tags" jsonb,
170
172
  "spec" jsonb NOT NULL,
171
173
  "state" jsonb NOT NULL,
174
+ "tenant_id" text,
175
+ "tenant_kind" text,
172
176
  "created_at" timestamp with time zone NOT NULL,
173
177
  "updated_at" timestamp with time zone NOT NULL
174
178
  )`,
179
+ // Tenancy columns (the customer a run / schedule belongs to): added in place on an existing database.
180
+ `ALTER TABLE "durable_workflow_runs" ADD COLUMN IF NOT EXISTS "tenant_id" text`,
181
+ `ALTER TABLE "durable_workflow_runs" ADD COLUMN IF NOT EXISTS "tenant_kind" text`,
182
+ `ALTER TABLE "durable_schedules" ADD COLUMN IF NOT EXISTS "tenant_id" text`,
183
+ `ALTER TABLE "durable_schedules" ADD COLUMN IF NOT EXISTS "tenant_kind" text`,
175
184
  `CREATE INDEX IF NOT EXISTS "durable_runs_status_idx" ON "durable_workflow_runs" USING btree ("status","wake_at")`,
176
185
  `CREATE INDEX IF NOT EXISTS "durable_runs_workflow_status_idx" ON "durable_workflow_runs" USING btree ("workflow","status")`,
177
186
  `CREATE INDEX IF NOT EXISTS "durable_workflow_runs_namespace_status_idx" ON "durable_workflow_runs" USING btree ("namespace","status","created_at")`,
@@ -184,6 +193,8 @@ var DURABLE_PG_DDL = [
184
193
  `CREATE INDEX IF NOT EXISTS "durable_buffered_signals_token_idx" ON "durable_buffered_signals" USING btree ("token","id")`,
185
194
  `CREATE INDEX IF NOT EXISTS "durable_buffered_events_name_published_at_idx" ON "durable_buffered_events" USING btree ("name","published_at")`,
186
195
  `CREATE INDEX IF NOT EXISTS "durable_schedules_due_idx" ON "durable_schedules" USING btree ("paused","next_fire_at")`,
196
+ `CREATE INDEX IF NOT EXISTS "durable_workflow_runs_tenant_idx" ON "durable_workflow_runs" USING btree ("tenant_id","created_at")`,
197
+ `CREATE INDEX IF NOT EXISTS "durable_schedules_tenant_idx" ON "durable_schedules" USING btree ("tenant_id")`,
187
198
  `CREATE INDEX IF NOT EXISTS "durable_signal_ids_expires_at_idx" ON "durable_signal_ids" USING btree ("expires_at")`
188
199
  ];
189
200
  var SCHEMA_LOCK_KEY = "durable_schema";
@@ -259,6 +270,74 @@ __name(ensureDrizzlePgDurableSchema, "ensureDrizzlePgDurableSchema");
259
270
  var import_nestjs_durable_core = require("@dudousxd/nestjs-durable-core");
260
271
  var import_drizzle_orm5 = require("drizzle-orm");
261
272
 
273
+ // src/tenant-columns.ts
274
+ var PG_STATEMENTS = [
275
+ 'ALTER TABLE "durable_workflow_runs" ADD COLUMN IF NOT EXISTS "tenant_id" text;',
276
+ 'ALTER TABLE "durable_workflow_runs" ADD COLUMN IF NOT EXISTS "tenant_kind" text;',
277
+ 'ALTER TABLE "durable_schedules" ADD COLUMN IF NOT EXISTS "tenant_id" text;',
278
+ 'ALTER TABLE "durable_schedules" ADD COLUMN IF NOT EXISTS "tenant_kind" text;',
279
+ 'CREATE INDEX IF NOT EXISTS "durable_workflow_runs_tenant_idx" ON "durable_workflow_runs" USING btree ("tenant_id","created_at");',
280
+ 'CREATE INDEX IF NOT EXISTS "durable_schedules_tenant_idx" ON "durable_schedules" USING btree ("tenant_id");'
281
+ ];
282
+ var SQLITE_STATEMENTS = [
283
+ "ALTER TABLE durable_workflow_runs ADD COLUMN tenant_id TEXT;",
284
+ "ALTER TABLE durable_workflow_runs ADD COLUMN tenant_kind TEXT;",
285
+ "ALTER TABLE durable_schedules ADD COLUMN tenant_id TEXT;",
286
+ "ALTER TABLE durable_schedules ADD COLUMN tenant_kind TEXT;",
287
+ "CREATE INDEX IF NOT EXISTS durable_workflow_runs_tenant_idx ON durable_workflow_runs (tenant_id, created_at);",
288
+ "CREATE INDEX IF NOT EXISTS durable_schedules_tenant_idx ON durable_schedules (tenant_id);"
289
+ ];
290
+ var TENANT_COLUMN = /tenant_(id|kind)/;
291
+ function isMissingTenantColumn(err) {
292
+ let cur = err;
293
+ for (let depth = 0; cur && depth < 5; depth += 1) {
294
+ const e = cur;
295
+ const message = typeof e.message === "string" ? e.message : "";
296
+ if (TENANT_COLUMN.test(message)) {
297
+ if (e.code === "42703" || /does not exist/.test(message) || /no such column/i.test(message)) {
298
+ return true;
299
+ }
300
+ }
301
+ cur = e.cause;
302
+ }
303
+ return false;
304
+ }
305
+ __name(isMissingTenantColumn, "isMissingTenantColumn");
306
+ var MissingTenantColumnsError = class extends Error {
307
+ static {
308
+ __name(this, "MissingTenantColumnsError");
309
+ }
310
+ constructor(dialect, cause) {
311
+ const statements = dialect === "pg" ? PG_STATEMENTS : SQLITE_STATEMENTS;
312
+ const fix = dialect === "pg" ? "Generate a migration with drizzle-kit (`drizzle-kit generate`) from the store schema and apply it, or turn on the module's `autoSchema`, which adds them on boot." : "Generate a migration with drizzle-kit (`drizzle-kit generate`) from the store schema and apply it.";
313
+ super([
314
+ "[nestjs-durable] The durable tables are missing the tenancy columns (tenant_id, tenant_kind).",
315
+ "This version of the Drizzle store reads them on every run and schedule query, even with tenancy off.",
316
+ fix,
317
+ "The migration must contain:",
318
+ ...statements.map((s) => ` ${s}`)
319
+ ].join("\n"), {
320
+ cause
321
+ });
322
+ this.name = "MissingTenantColumnsError";
323
+ }
324
+ };
325
+ function tenantColumnsHint(dialect) {
326
+ return (err) => {
327
+ if (isMissingTenantColumn(err)) throw new MissingTenantColumnsError(dialect, err);
328
+ throw err;
329
+ };
330
+ }
331
+ __name(tenantColumnsHint, "tenantColumnsHint");
332
+ async function withTenantColumnsHint(dialect, query) {
333
+ try {
334
+ return await query;
335
+ } catch (err) {
336
+ return tenantColumnsHint(dialect)(err);
337
+ }
338
+ }
339
+ __name(withTenantColumnsHint, "withTenantColumnsHint");
340
+
262
341
  // src/pg/hot-path.ts
263
342
  var drizzleOrm = __toESM(require("drizzle-orm"), 1);
264
343
  var import_drizzle_orm3 = require("drizzle-orm");
@@ -402,9 +481,14 @@ var durableWorkflowRuns = (0, import_pg_core.pgTable)("durable_workflow_runs", {
402
481
  namespace: (0, import_pg_core.text)("namespace").notNull().default(DEFAULT_NAMESPACE),
403
482
  // Which package declared the workflow. Nullable, no default: NULL = unknown, never guessed.
404
483
  origin: (0, import_pg_core.text)("origin"),
484
+ // The customer (tenancy) the run belongs to — not the worker-pool `namespace`. NULL = none.
485
+ tenantId: (0, import_pg_core.text)("tenant_id"),
486
+ tenantKind: (0, import_pg_core.text)("tenant_kind"),
405
487
  createdAt: tstz("created_at").notNull(),
406
488
  updatedAt: tstz("updated_at").notNull()
407
489
  }, (t) => [
490
+ // App-facing reads with tenancy on: `tenant_id = $1 ORDER BY created_at DESC`.
491
+ (0, import_pg_core.index)("durable_workflow_runs_tenant_idx").on(t.tenantId, t.createdAt),
408
492
  // Timer poller (`listDueTimers`) + recovery (`listIncompleteRuns`). Same name as the TypeORM DDL.
409
493
  (0, import_pg_core.index)("durable_runs_status_idx").on(t.status, t.wakeAt),
410
494
  // Dashboard `listRuns({ workflow, status })` and the singleton gate's per-workflow scans.
@@ -526,12 +610,16 @@ var durableSchedules = (0, import_pg_core.pgTable)(
526
610
  tags: (0, import_pg_core.jsonb)("tags").$type(),
527
611
  spec: (0, import_pg_core.jsonb)("spec").$type().notNull(),
528
612
  state: (0, import_pg_core.jsonb)("state").$type().notNull(),
613
+ // The customer the schedule (and every run it starts) belongs to. NULL = none.
614
+ tenantId: (0, import_pg_core.text)("tenant_id"),
615
+ tenantKind: (0, import_pg_core.text)("tenant_kind"),
529
616
  createdAt: tstz("created_at").notNull(),
530
617
  updatedAt: tstz("updated_at").notNull()
531
618
  },
532
619
  // The poll's "due by T" scan: `paused = false AND next_fire_at <= T ORDER BY next_fire_at`.
533
620
  (t) => [
534
- (0, import_pg_core.index)("durable_schedules_due_idx").on(t.paused, t.nextFireAt)
621
+ (0, import_pg_core.index)("durable_schedules_due_idx").on(t.paused, t.nextFireAt),
622
+ (0, import_pg_core.index)("durable_schedules_tenant_idx").on(t.tenantId)
535
623
  ]
536
624
  );
537
625
  var durablePgSchema = {
@@ -558,6 +646,14 @@ function anyOf(conditions) {
558
646
  return present.length ? (0, import_drizzle_orm5.or)(...present) : import_drizzle_orm5.sql`1 = 0`;
559
647
  }
560
648
  __name(anyOf, "anyOf");
649
+ function tenantFilters(column, query) {
650
+ const one = /* @__PURE__ */ __name((id) => id === null ? (0, import_drizzle_orm5.isNull)(column) : (0, import_drizzle_orm5.eq)(column, id), "one");
651
+ return [
652
+ query.tenantId !== void 0 ? one(query.tenantId) : void 0,
653
+ query.tenantIds ? anyOf(query.tenantIds.map(one)) : void 0
654
+ ];
655
+ }
656
+ __name(tenantFilters, "tenantFilters");
561
657
  function namespaceFilter(namespace) {
562
658
  if (namespace === void 0) return void 0;
563
659
  if (namespace === DEFAULT_NAMESPACE || namespace === "") {
@@ -1017,15 +1113,15 @@ var DrizzlePgStateStore = class _DrizzlePgStateStore {
1017
1113
  }
1018
1114
  /** Crash recovery. Namespace-scoped: a worker re-drives only its own tenant's runs. */
1019
1115
  async listIncompleteRuns(namespace) {
1020
- const rows = await this.db.select().from(durableWorkflowRuns).where((0, import_drizzle_orm5.and)((0, import_drizzle_orm5.inArray)(durableWorkflowRuns.status, [
1116
+ const rows = await withTenantColumnsHint("pg", this.db.select().from(durableWorkflowRuns).where((0, import_drizzle_orm5.and)((0, import_drizzle_orm5.inArray)(durableWorkflowRuns.status, [
1021
1117
  "running",
1022
1118
  "cancelling"
1023
- ]), namespaceFilter(namespace), this.scope()));
1119
+ ]), namespaceFilter(namespace), this.scope())));
1024
1120
  return rows.map(fromRunRow);
1025
1121
  }
1026
1122
  async listOrphanedRuns(nowMs, limit, namespace, ownedBy) {
1027
1123
  if (limit <= 0) return [];
1028
- const rows = await this.db.select().from(durableWorkflowRuns).where((0, import_drizzle_orm5.and)((0, import_drizzle_orm5.inArray)(durableWorkflowRuns.status, [
1124
+ const query = this.db.select().from(durableWorkflowRuns).where((0, import_drizzle_orm5.and)((0, import_drizzle_orm5.inArray)(durableWorkflowRuns.status, [
1029
1125
  "running",
1030
1126
  "cancelling"
1031
1127
  ]), (0, import_drizzle_orm5.or)(
@@ -1034,12 +1130,13 @@ var DrizzlePgStateStore = class _DrizzlePgStateStore {
1034
1130
  // A live lease left by a previous process with the caller's own instance id.
1035
1131
  ownedBy ? (0, import_drizzle_orm5.and)((0, import_drizzle_orm5.eq)(durableWorkflowRuns.lockedBy, ownedBy.owner), (0, import_drizzle_orm5.lt)(durableWorkflowRuns.lockedUntil, new Date(ownedBy.lockedBefore))) : void 0
1036
1132
  ), namespaceFilter(namespace), this.scope())).orderBy((0, import_drizzle_orm5.asc)(durableWorkflowRuns.createdAt)).limit(limit);
1133
+ const rows = await withTenantColumnsHint("pg", query);
1037
1134
  return rows.map(fromRunRow);
1038
1135
  }
1039
1136
  /** FIFO pick-up, served by `durable_workflow_runs_namespace_status_idx`. The engine then leases
1040
1137
  * each run with {@link tryLockRun}; the listing itself takes no locks (it runs outside a tx). */
1041
1138
  async listPendingRuns(limit, namespace) {
1042
- const rows = await this.db.select().from(durableWorkflowRuns).where((0, import_drizzle_orm5.and)((0, import_drizzle_orm5.eq)(durableWorkflowRuns.status, "pending"), namespaceFilter(namespace), this.scope())).orderBy((0, import_drizzle_orm5.asc)(durableWorkflowRuns.createdAt)).limit(limit);
1139
+ const rows = await withTenantColumnsHint("pg", this.db.select().from(durableWorkflowRuns).where((0, import_drizzle_orm5.and)((0, import_drizzle_orm5.eq)(durableWorkflowRuns.status, "pending"), namespaceFilter(namespace), this.scope())).orderBy((0, import_drizzle_orm5.asc)(durableWorkflowRuns.createdAt)).limit(limit));
1043
1140
  return rows.map(fromRunRow);
1044
1141
  }
1045
1142
  async claimPendingRuns(limit, owner, leaseUntilMs, nowMs, namespace) {
@@ -1050,7 +1147,7 @@ var DrizzlePgStateStore = class _DrizzlePgStateStore {
1050
1147
  // A CTE, MATERIALIZED, picks the rows once. As a subquery in UPDATE ... FROM, Postgres may
1051
1148
  // rescan it, and each rescan skips the rows this statement already updated and takes the
1052
1149
  // next ones, so a claim of `limit` rows could lease every free pending run.
1053
- await this.db.execute(import_drizzle_orm5.sql`WITH c AS MATERIALIZED (
1150
+ await withTenantColumnsHint("pg", this.db.execute(import_drizzle_orm5.sql`WITH c AS MATERIALIZED (
1054
1151
  SELECT ${durableWorkflowRuns.id} AS claimed_id FROM ${durableWorkflowRuns}
1055
1152
  WHERE ${filters}
1056
1153
  ORDER BY ${durableWorkflowRuns.createdAt}, ${durableWorkflowRuns.id}
@@ -1062,13 +1159,13 @@ var DrizzlePgStateStore = class _DrizzlePgStateStore {
1062
1159
  ${import_drizzle_orm5.sql.identifier((0, import_drizzle_orm5.getTableColumns)(durableWorkflowRuns).lockedUntil.name)} = ${new Date(leaseUntilMs).toISOString()}::timestamptz
1063
1160
  FROM c
1064
1161
  WHERE r.${import_drizzle_orm5.sql.identifier((0, import_drizzle_orm5.getTableColumns)(durableWorkflowRuns).id.name)} = c.claimed_id
1065
- RETURNING ${returning}`)
1162
+ RETURNING ${returning}`))
1066
1163
  );
1067
1164
  return rows.map((raw) => fromRunRow(RUNS.decode(raw))).sort((a, b) => a.createdAt.getTime() - b.createdAt.getTime() || a.id.localeCompare(b.id));
1068
1165
  }
1069
1166
  async listDueTimers(nowMs, namespace, limit) {
1070
1167
  const query = this.db.select().from(durableWorkflowRuns).where((0, import_drizzle_orm5.and)((0, import_drizzle_orm5.eq)(durableWorkflowRuns.status, "suspended"), (0, import_drizzle_orm5.isNotNull)(durableWorkflowRuns.wakeAt), (0, import_drizzle_orm5.lte)(durableWorkflowRuns.wakeAt, new Date(nowMs)), namespaceFilter(namespace), this.scope())).orderBy((0, import_drizzle_orm5.asc)(durableWorkflowRuns.wakeAt));
1071
- const rows = limit !== void 0 ? await query.limit(limit) : await query;
1168
+ const rows = await withTenantColumnsHint("pg", limit !== void 0 ? query.limit(limit) : query);
1072
1169
  return rows.map(fromRunRow);
1073
1170
  }
1074
1171
  async tryLockRun(runId, owner, leaseUntilMs, nowMs) {
@@ -1135,6 +1232,8 @@ var DrizzlePgStateStore = class _DrizzlePgStateStore {
1135
1232
  // `null` selects the unattributed bucket; a value never matches a NULL origin.
1136
1233
  query.origin === null ? (0, import_drizzle_orm5.isNull)(durableWorkflowRuns.origin) : query.origin !== void 0 ? (0, import_drizzle_orm5.eq)(durableWorkflowRuns.origin, query.origin) : void 0,
1137
1234
  query.origins ? anyOf(query.origins.map((o) => o === null ? (0, import_drizzle_orm5.isNull)(durableWorkflowRuns.origin) : (0, import_drizzle_orm5.eq)(durableWorkflowRuns.origin, o))) : void 0,
1235
+ // The customer (tenancy matching rule): `null` = runs with no tenant.
1236
+ ...tenantFilters(durableWorkflowRuns.tenantId, query),
1138
1237
  query.status ? (0, import_drizzle_orm5.eq)(durableWorkflowRuns.status, query.status) : void 0,
1139
1238
  query.statuses ? query.statuses.length ? (0, import_drizzle_orm5.inArray)(durableWorkflowRuns.status, query.statuses) : import_drizzle_orm5.sql`1 = 0` : void 0,
1140
1239
  query.tag ? hasTag(query.tag) : void 0,
@@ -1231,10 +1330,10 @@ var DrizzlePgStateStore = class _DrizzlePgStateStore {
1231
1330
  async listSchedules(query) {
1232
1331
  const base = this.db.select().from(durableSchedules).where((0, import_drizzle_orm5.and)(query.namespace !== void 0 ? (0, import_drizzle_orm5.eq)(durableSchedules.namespace, query.namespace) : void 0, query.workflow !== void 0 ? (0, import_drizzle_orm5.eq)(durableSchedules.workflow, query.workflow) : void 0, query.paused !== void 0 ? (0, import_drizzle_orm5.eq)(durableSchedules.paused, query.paused) : void 0, query.tag !== void 0 ? import_drizzle_orm5.sql`${durableSchedules.tags} @> ${JSON.stringify([
1233
1332
  query.tag
1234
- ])}::jsonb` : void 0, query.dueBy !== void 0 ? (0, import_drizzle_orm5.and)((0, import_drizzle_orm5.eq)(durableSchedules.paused, false), (0, import_drizzle_orm5.lte)(durableSchedules.nextFireAt, new Date(query.dueBy))) : void 0)).orderBy(import_drizzle_orm5.sql`${durableSchedules.nextFireAt} ASC NULLS LAST`, (0, import_drizzle_orm5.asc)(durableSchedules.id)).$dynamic();
1333
+ ])}::jsonb` : void 0, ...tenantFilters(durableSchedules.tenantId, query), query.dueBy !== void 0 ? (0, import_drizzle_orm5.and)((0, import_drizzle_orm5.eq)(durableSchedules.paused, false), (0, import_drizzle_orm5.lte)(durableSchedules.nextFireAt, new Date(query.dueBy))) : void 0)).orderBy(import_drizzle_orm5.sql`${durableSchedules.nextFireAt} ASC NULLS LAST`, (0, import_drizzle_orm5.asc)(durableSchedules.id)).$dynamic();
1235
1334
  if (query.limit != null) base.limit(query.limit);
1236
1335
  if (query.offset != null) base.offset(query.offset);
1237
- return (await base).map(fromScheduleRow);
1336
+ return (await withTenantColumnsHint("pg", base)).map(fromScheduleRow);
1238
1337
  }
1239
1338
  async listCheckpoints(runId) {
1240
1339
  const rows = await this.db.select().from(durableStepCheckpoints).where((0, import_drizzle_orm5.eq)(durableStepCheckpoints.runId, runId)).orderBy((0, import_drizzle_orm5.asc)(durableStepCheckpoints.seq));
@@ -1776,6 +1875,8 @@ function toRunRow(run) {
1776
1875
  priority: run.priority ?? null,
1777
1876
  namespace: run.namespace || DEFAULT_NAMESPACE,
1778
1877
  origin: run.origin ?? null,
1878
+ tenantId: run.tenantId ?? null,
1879
+ tenantKind: run.tenantKind ?? null,
1779
1880
  createdAt: run.createdAt,
1780
1881
  updatedAt: run.updatedAt
1781
1882
  };
@@ -1799,6 +1900,8 @@ function toRunPatch(patch) {
1799
1900
  if ("priority" in patch) row.priority = patch.priority ?? null;
1800
1901
  if ("namespace" in patch) row.namespace = patch.namespace || DEFAULT_NAMESPACE;
1801
1902
  if ("origin" in patch) row.origin = patch.origin ?? null;
1903
+ if ("tenantId" in patch) row.tenantId = patch.tenantId ?? null;
1904
+ if ("tenantKind" in patch) row.tenantKind = patch.tenantKind ?? null;
1802
1905
  if (patch.createdAt != null) row.createdAt = patch.createdAt;
1803
1906
  if (patch.updatedAt != null) row.updatedAt = patch.updatedAt;
1804
1907
  return row;
@@ -1823,6 +1926,13 @@ function fromRunRow(row) {
1823
1926
  priority: row.priority ?? void 0,
1824
1927
  namespace: row.namespace || DEFAULT_NAMESPACE,
1825
1928
  origin: row.origin ?? void 0,
1929
+ // NULL = no tenant; left off entirely so a tenancy-off run reads back unchanged.
1930
+ ...row.tenantId != null ? {
1931
+ tenantId: row.tenantId
1932
+ } : {},
1933
+ ...row.tenantKind != null ? {
1934
+ tenantKind: row.tenantKind
1935
+ } : {},
1826
1936
  createdAt: row.createdAt,
1827
1937
  updatedAt: row.updatedAt
1828
1938
  };
@@ -1883,6 +1993,8 @@ function toScheduleRow(r) {
1883
1993
  tags: r.tags ?? null,
1884
1994
  spec: r.spec,
1885
1995
  state: r.state,
1996
+ tenantId: r.tenantId ?? null,
1997
+ tenantKind: r.tenantKind ?? null,
1886
1998
  createdAt: r.createdAt,
1887
1999
  updatedAt: r.updatedAt
1888
2000
  };
@@ -1897,6 +2009,8 @@ function toSchedulePatch(patch) {
1897
2009
  if ("tags" in patch) set.tags = patch.tags ?? null;
1898
2010
  if (patch.spec !== void 0) set.spec = patch.spec;
1899
2011
  if (patch.state !== void 0) set.state = patch.state;
2012
+ if ("tenantId" in patch) set.tenantId = patch.tenantId ?? null;
2013
+ if ("tenantKind" in patch) set.tenantKind = patch.tenantKind ?? null;
1900
2014
  if (patch.updatedAt !== void 0) set.updatedAt = patch.updatedAt;
1901
2015
  return set;
1902
2016
  }
@@ -1913,6 +2027,12 @@ function fromScheduleRow(row) {
1913
2027
  } : {},
1914
2028
  spec: row.spec ?? {},
1915
2029
  state: row.state ?? {},
2030
+ ...row.tenantId != null ? {
2031
+ tenantId: row.tenantId
2032
+ } : {},
2033
+ ...row.tenantKind != null ? {
2034
+ tenantKind: row.tenantKind
2035
+ } : {},
1916
2036
  createdAt: row.createdAt,
1917
2037
  updatedAt: row.updatedAt
1918
2038
  };