@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.cjs +49 -9
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +5 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.js +49 -9
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
- package/prisma/schema.prisma +14 -0
package/dist/index.cjs
CHANGED
|
@@ -685,6 +685,12 @@ var PrismaStateStore = class {
|
|
|
685
685
|
if (query.origins) and.push(anyOf(query.origins.map((o) => ({
|
|
686
686
|
origin: o
|
|
687
687
|
}))));
|
|
688
|
+
if (query.tenantId !== void 0) and.push({
|
|
689
|
+
tenantId: query.tenantId
|
|
690
|
+
});
|
|
691
|
+
if (query.tenantIds) and.push(anyOf(query.tenantIds.map((t) => ({
|
|
692
|
+
tenantId: t
|
|
693
|
+
}))));
|
|
688
694
|
if (query.status && query.statuses) {
|
|
689
695
|
and.push({
|
|
690
696
|
status: query.status
|
|
@@ -811,6 +817,8 @@ var PrismaStateStore = class {
|
|
|
811
817
|
if ("tags" in patch) data.tags = jsonOrNull(patch.tags);
|
|
812
818
|
if (patch.spec !== void 0) data.spec = patch.spec;
|
|
813
819
|
if (patch.state !== void 0) data.state = patch.state;
|
|
820
|
+
if ("tenantId" in patch) data.tenantId = patch.tenantId ?? null;
|
|
821
|
+
if ("tenantKind" in patch) data.tenantKind = patch.tenantKind ?? null;
|
|
814
822
|
if (patch.updatedAt !== void 0) data.updatedAt = patch.updatedAt;
|
|
815
823
|
if (!Object.keys(data).length) return await this.getSchedule(id) !== null;
|
|
816
824
|
const where = {
|
|
@@ -839,18 +847,23 @@ var PrismaStateStore = class {
|
|
|
839
847
|
if (query.tag !== void 0) where.tags = {
|
|
840
848
|
array_contains: query.tag
|
|
841
849
|
};
|
|
850
|
+
const and = [];
|
|
851
|
+
if (query.tenantId !== void 0) and.push({
|
|
852
|
+
tenantId: query.tenantId
|
|
853
|
+
});
|
|
854
|
+
if (query.tenantIds) and.push(anyOf(query.tenantIds.map((t) => ({
|
|
855
|
+
tenantId: t
|
|
856
|
+
}))));
|
|
842
857
|
if (query.dueBy !== void 0) {
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
nextFireAt: {
|
|
849
|
-
lte: BigInt(query.dueBy)
|
|
850
|
-
}
|
|
858
|
+
and.push({
|
|
859
|
+
paused: false
|
|
860
|
+
}, {
|
|
861
|
+
nextFireAt: {
|
|
862
|
+
lte: BigInt(query.dueBy)
|
|
851
863
|
}
|
|
852
|
-
|
|
864
|
+
});
|
|
853
865
|
}
|
|
866
|
+
if (and.length) where.AND = and;
|
|
854
867
|
const rows = await this.schedules().findMany({
|
|
855
868
|
where,
|
|
856
869
|
// Soonest-due first, never-firing (NULL) last, id as the stable tie-break.
|
|
@@ -1515,6 +1528,8 @@ function toRunData(run) {
|
|
|
1515
1528
|
namespace: run.namespace || "default",
|
|
1516
1529
|
// Absent origin stays SQL NULL — "unknown", never coerced into a real-looking library name.
|
|
1517
1530
|
origin: run.origin ?? null,
|
|
1531
|
+
tenantId: run.tenantId ?? null,
|
|
1532
|
+
tenantKind: run.tenantKind ?? null,
|
|
1518
1533
|
createdAt: run.createdAt,
|
|
1519
1534
|
updatedAt: run.updatedAt
|
|
1520
1535
|
};
|
|
@@ -1538,6 +1553,8 @@ function toRunPatch(patch) {
|
|
|
1538
1553
|
if ("priority" in patch) data.priority = patch.priority ?? null;
|
|
1539
1554
|
if ("namespace" in patch) data.namespace = patch.namespace || "default";
|
|
1540
1555
|
if ("origin" in patch) data.origin = patch.origin ?? null;
|
|
1556
|
+
if ("tenantId" in patch) data.tenantId = patch.tenantId ?? null;
|
|
1557
|
+
if ("tenantKind" in patch) data.tenantKind = patch.tenantKind ?? null;
|
|
1541
1558
|
if (patch.createdAt != null) data.createdAt = patch.createdAt;
|
|
1542
1559
|
if (patch.updatedAt != null) data.updatedAt = patch.updatedAt;
|
|
1543
1560
|
return data;
|
|
@@ -1568,6 +1585,13 @@ function fromRunRow(row) {
|
|
|
1568
1585
|
namespace: row.namespace,
|
|
1569
1586
|
// NULL (a row written before the column existed) surfaces as `undefined` = unknown origin.
|
|
1570
1587
|
origin: row.origin ?? void 0,
|
|
1588
|
+
// NULL = no tenant; left off entirely so a tenancy-off run reads back unchanged.
|
|
1589
|
+
...row.tenantId != null ? {
|
|
1590
|
+
tenantId: row.tenantId
|
|
1591
|
+
} : {},
|
|
1592
|
+
...row.tenantKind != null ? {
|
|
1593
|
+
tenantKind: row.tenantKind
|
|
1594
|
+
} : {},
|
|
1571
1595
|
createdAt: row.createdAt,
|
|
1572
1596
|
updatedAt: row.updatedAt
|
|
1573
1597
|
};
|
|
@@ -1849,6 +1873,8 @@ function toScheduleData(r) {
|
|
|
1849
1873
|
tags: jsonOrNull(r.tags),
|
|
1850
1874
|
spec: r.spec,
|
|
1851
1875
|
state: r.state,
|
|
1876
|
+
tenantId: r.tenantId ?? null,
|
|
1877
|
+
tenantKind: r.tenantKind ?? null,
|
|
1852
1878
|
createdAt: r.createdAt,
|
|
1853
1879
|
updatedAt: r.updatedAt
|
|
1854
1880
|
};
|
|
@@ -1867,6 +1893,12 @@ function fromScheduleRow(row) {
|
|
|
1867
1893
|
} : {},
|
|
1868
1894
|
spec: row.spec ?? {},
|
|
1869
1895
|
state: row.state ?? {},
|
|
1896
|
+
...row.tenantId != null ? {
|
|
1897
|
+
tenantId: row.tenantId
|
|
1898
|
+
} : {},
|
|
1899
|
+
...row.tenantKind != null ? {
|
|
1900
|
+
tenantKind: row.tenantKind
|
|
1901
|
+
} : {},
|
|
1870
1902
|
createdAt: row.createdAt,
|
|
1871
1903
|
updatedAt: row.updatedAt
|
|
1872
1904
|
};
|
|
@@ -2089,6 +2121,14 @@ var PrismaRoundTrips = class PrismaRoundTrips2 {
|
|
|
2089
2121
|
"origin",
|
|
2090
2122
|
"text"
|
|
2091
2123
|
],
|
|
2124
|
+
tenantId: [
|
|
2125
|
+
"tenant_id",
|
|
2126
|
+
"text"
|
|
2127
|
+
],
|
|
2128
|
+
tenantKind: [
|
|
2129
|
+
"tenant_kind",
|
|
2130
|
+
"text"
|
|
2131
|
+
],
|
|
2092
2132
|
updatedAt: [
|
|
2093
2133
|
"updated_at",
|
|
2094
2134
|
"date"
|