@dudousxd/nestjs-durable-store-prisma 0.26.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/dist/index.d.cts CHANGED
@@ -19,6 +19,9 @@ interface RunRow {
19
19
  /** NOT NULL in the schema (defaulted to `'default'`), so every row carries a real namespace. */
20
20
  namespace: string;
21
21
  origin: string | null;
22
+ /** The customer (tenancy); NULL = none. */
23
+ tenantId: string | null;
24
+ tenantKind: string | null;
22
25
  createdAt: Date;
23
26
  updatedAt: Date;
24
27
  }
@@ -101,6 +104,8 @@ interface ScheduleRow {
101
104
  tags: unknown;
102
105
  spec: unknown;
103
106
  state: unknown;
107
+ tenantId: string | null;
108
+ tenantKind: string | null;
104
109
  createdAt: Date;
105
110
  updatedAt: Date;
106
111
  }
package/dist/index.d.ts CHANGED
@@ -19,6 +19,9 @@ interface RunRow {
19
19
  /** NOT NULL in the schema (defaulted to `'default'`), so every row carries a real namespace. */
20
20
  namespace: string;
21
21
  origin: string | null;
22
+ /** The customer (tenancy); NULL = none. */
23
+ tenantId: string | null;
24
+ tenantKind: string | null;
22
25
  createdAt: Date;
23
26
  updatedAt: Date;
24
27
  }
@@ -101,6 +104,8 @@ interface ScheduleRow {
101
104
  tags: unknown;
102
105
  spec: unknown;
103
106
  state: unknown;
107
+ tenantId: string | null;
108
+ tenantKind: string | null;
104
109
  createdAt: Date;
105
110
  updatedAt: Date;
106
111
  }
package/dist/index.js CHANGED
@@ -660,6 +660,12 @@ var PrismaStateStore = class {
660
660
  if (query.origins) and.push(anyOf(query.origins.map((o) => ({
661
661
  origin: o
662
662
  }))));
663
+ if (query.tenantId !== void 0) and.push({
664
+ tenantId: query.tenantId
665
+ });
666
+ if (query.tenantIds) and.push(anyOf(query.tenantIds.map((t) => ({
667
+ tenantId: t
668
+ }))));
663
669
  if (query.status && query.statuses) {
664
670
  and.push({
665
671
  status: query.status
@@ -786,6 +792,8 @@ var PrismaStateStore = class {
786
792
  if ("tags" in patch) data.tags = jsonOrNull(patch.tags);
787
793
  if (patch.spec !== void 0) data.spec = patch.spec;
788
794
  if (patch.state !== void 0) data.state = patch.state;
795
+ if ("tenantId" in patch) data.tenantId = patch.tenantId ?? null;
796
+ if ("tenantKind" in patch) data.tenantKind = patch.tenantKind ?? null;
789
797
  if (patch.updatedAt !== void 0) data.updatedAt = patch.updatedAt;
790
798
  if (!Object.keys(data).length) return await this.getSchedule(id) !== null;
791
799
  const where = {
@@ -814,18 +822,23 @@ var PrismaStateStore = class {
814
822
  if (query.tag !== void 0) where.tags = {
815
823
  array_contains: query.tag
816
824
  };
825
+ const and = [];
826
+ if (query.tenantId !== void 0) and.push({
827
+ tenantId: query.tenantId
828
+ });
829
+ if (query.tenantIds) and.push(anyOf(query.tenantIds.map((t) => ({
830
+ tenantId: t
831
+ }))));
817
832
  if (query.dueBy !== void 0) {
818
- where.AND = [
819
- {
820
- paused: false
821
- },
822
- {
823
- nextFireAt: {
824
- lte: BigInt(query.dueBy)
825
- }
833
+ and.push({
834
+ paused: false
835
+ }, {
836
+ nextFireAt: {
837
+ lte: BigInt(query.dueBy)
826
838
  }
827
- ];
839
+ });
828
840
  }
841
+ if (and.length) where.AND = and;
829
842
  const rows = await this.schedules().findMany({
830
843
  where,
831
844
  // Soonest-due first, never-firing (NULL) last, id as the stable tie-break.
@@ -1490,6 +1503,8 @@ function toRunData(run) {
1490
1503
  namespace: run.namespace || "default",
1491
1504
  // Absent origin stays SQL NULL — "unknown", never coerced into a real-looking library name.
1492
1505
  origin: run.origin ?? null,
1506
+ tenantId: run.tenantId ?? null,
1507
+ tenantKind: run.tenantKind ?? null,
1493
1508
  createdAt: run.createdAt,
1494
1509
  updatedAt: run.updatedAt
1495
1510
  };
@@ -1513,6 +1528,8 @@ function toRunPatch(patch) {
1513
1528
  if ("priority" in patch) data.priority = patch.priority ?? null;
1514
1529
  if ("namespace" in patch) data.namespace = patch.namespace || "default";
1515
1530
  if ("origin" in patch) data.origin = patch.origin ?? null;
1531
+ if ("tenantId" in patch) data.tenantId = patch.tenantId ?? null;
1532
+ if ("tenantKind" in patch) data.tenantKind = patch.tenantKind ?? null;
1516
1533
  if (patch.createdAt != null) data.createdAt = patch.createdAt;
1517
1534
  if (patch.updatedAt != null) data.updatedAt = patch.updatedAt;
1518
1535
  return data;
@@ -1543,6 +1560,13 @@ function fromRunRow(row) {
1543
1560
  namespace: row.namespace,
1544
1561
  // NULL (a row written before the column existed) surfaces as `undefined` = unknown origin.
1545
1562
  origin: row.origin ?? void 0,
1563
+ // NULL = no tenant; left off entirely so a tenancy-off run reads back unchanged.
1564
+ ...row.tenantId != null ? {
1565
+ tenantId: row.tenantId
1566
+ } : {},
1567
+ ...row.tenantKind != null ? {
1568
+ tenantKind: row.tenantKind
1569
+ } : {},
1546
1570
  createdAt: row.createdAt,
1547
1571
  updatedAt: row.updatedAt
1548
1572
  };
@@ -1824,6 +1848,8 @@ function toScheduleData(r) {
1824
1848
  tags: jsonOrNull(r.tags),
1825
1849
  spec: r.spec,
1826
1850
  state: r.state,
1851
+ tenantId: r.tenantId ?? null,
1852
+ tenantKind: r.tenantKind ?? null,
1827
1853
  createdAt: r.createdAt,
1828
1854
  updatedAt: r.updatedAt
1829
1855
  };
@@ -1842,6 +1868,12 @@ function fromScheduleRow(row) {
1842
1868
  } : {},
1843
1869
  spec: row.spec ?? {},
1844
1870
  state: row.state ?? {},
1871
+ ...row.tenantId != null ? {
1872
+ tenantId: row.tenantId
1873
+ } : {},
1874
+ ...row.tenantKind != null ? {
1875
+ tenantKind: row.tenantKind
1876
+ } : {},
1845
1877
  createdAt: row.createdAt,
1846
1878
  updatedAt: row.updatedAt
1847
1879
  };
@@ -2064,6 +2096,14 @@ var PrismaRoundTrips = class PrismaRoundTrips2 {
2064
2096
  "origin",
2065
2097
  "text"
2066
2098
  ],
2099
+ tenantId: [
2100
+ "tenant_id",
2101
+ "text"
2102
+ ],
2103
+ tenantKind: [
2104
+ "tenant_kind",
2105
+ "text"
2106
+ ],
2067
2107
  updatedAt: [
2068
2108
  "updated_at",
2069
2109
  "date"