@dudousxd/nestjs-durable-core 0.66.0 → 0.67.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 +56 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +73 -4
- package/dist/index.d.ts +73 -4
- package/dist/index.js +54 -2
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -89,6 +89,7 @@ __export(index_exports, {
|
|
|
89
89
|
eventNameOf: () => eventNameOf,
|
|
90
90
|
eventPrefix: () => eventPrefix,
|
|
91
91
|
eventToken: () => eventToken,
|
|
92
|
+
facetOrigin: () => facetOrigin,
|
|
92
93
|
hasDurableExecutionWrappers: () => hasDurableExecutionWrappers,
|
|
93
94
|
heartbeatStatus: () => heartbeatStatus,
|
|
94
95
|
indexWaitersByRun: () => indexWaitersByRun,
|
|
@@ -98,6 +99,7 @@ __export(index_exports, {
|
|
|
98
99
|
isWorkflowControlFlowSignal: () => isWorkflowControlFlowSignal,
|
|
99
100
|
log: () => log,
|
|
100
101
|
matchesAttributes: () => matchesAttributes,
|
|
102
|
+
mergeRunFacetRows: () => mergeRunFacetRows,
|
|
101
103
|
missingCapabilities: () => missingCapabilities,
|
|
102
104
|
negotiate: () => negotiate,
|
|
103
105
|
normalizeAttributeRows: () => normalizeAttributeRows,
|
|
@@ -6106,6 +6108,33 @@ var TERMINAL_RUN_STATUSES = [
|
|
|
6106
6108
|
"dead"
|
|
6107
6109
|
];
|
|
6108
6110
|
|
|
6111
|
+
// src/run-facets.ts
|
|
6112
|
+
function facetOrigin(origin) {
|
|
6113
|
+
return origin?.trim() ? origin : null;
|
|
6114
|
+
}
|
|
6115
|
+
__name(facetOrigin, "facetOrigin");
|
|
6116
|
+
function mergeRunFacetRows(rows) {
|
|
6117
|
+
const cells = /* @__PURE__ */ new Map();
|
|
6118
|
+
for (const row of rows) {
|
|
6119
|
+
const origin = facetOrigin(row.origin);
|
|
6120
|
+
const key = JSON.stringify([
|
|
6121
|
+
row.status,
|
|
6122
|
+
origin
|
|
6123
|
+
]);
|
|
6124
|
+
const cell = cells.get(key);
|
|
6125
|
+
if (cell) cell.count += row.count;
|
|
6126
|
+
else cells.set(key, {
|
|
6127
|
+
status: row.status,
|
|
6128
|
+
origin,
|
|
6129
|
+
count: row.count
|
|
6130
|
+
});
|
|
6131
|
+
}
|
|
6132
|
+
return [
|
|
6133
|
+
...cells.values()
|
|
6134
|
+
];
|
|
6135
|
+
}
|
|
6136
|
+
__name(mergeRunFacetRows, "mergeRunFacetRows");
|
|
6137
|
+
|
|
6109
6138
|
// src/run-gateway.ts
|
|
6110
6139
|
var RunGateway = class {
|
|
6111
6140
|
static {
|
|
@@ -6120,9 +6149,18 @@ var CodecStateStore = class {
|
|
|
6120
6149
|
}
|
|
6121
6150
|
inner;
|
|
6122
6151
|
codec;
|
|
6152
|
+
/**
|
|
6153
|
+
* Forwarded verbatim — a facet cell counts `status`/`origin`, neither of which the codec touches
|
|
6154
|
+
* (it encodes payloads: input/output/error). Bound as a PROPERTY, and only when the inner store
|
|
6155
|
+
* actually aggregates, so `store.runFacets?.()` still reports absence through the wrapper instead
|
|
6156
|
+
* of resolving to a silently wrong empty result.
|
|
6157
|
+
*/
|
|
6158
|
+
runFacets;
|
|
6123
6159
|
constructor(inner, codec) {
|
|
6124
6160
|
this.inner = inner;
|
|
6125
6161
|
this.codec = codec;
|
|
6162
|
+
const facets = inner.runFacets;
|
|
6163
|
+
if (facets) this.runFacets = (query) => facets.call(inner, query);
|
|
6126
6164
|
}
|
|
6127
6165
|
enc(v) {
|
|
6128
6166
|
return v === void 0 ? void 0 : this.codec.encode(v);
|
|
@@ -6820,7 +6858,9 @@ var InMemoryStateStore = class {
|
|
|
6820
6858
|
}
|
|
6821
6859
|
return out;
|
|
6822
6860
|
}
|
|
6823
|
-
|
|
6861
|
+
/** Every run satisfying `query`'s predicates, unsorted and unpaged — the shared body of
|
|
6862
|
+
* {@link listRuns} (which then sorts + pages it) and {@link runFacets} (which groups it). */
|
|
6863
|
+
matching(query) {
|
|
6824
6864
|
let runs = [
|
|
6825
6865
|
...this.runs.values()
|
|
6826
6866
|
];
|
|
@@ -6829,7 +6869,8 @@ var InMemoryStateStore = class {
|
|
|
6829
6869
|
if (query.statuses) runs = runs.filter((r) => query.statuses?.includes(r.status));
|
|
6830
6870
|
if (query.tag) runs = runs.filter((r) => r.tags?.includes(query.tag));
|
|
6831
6871
|
if (query.namespace !== void 0) runs = runs.filter((r) => r.namespace === query.namespace);
|
|
6832
|
-
if (query.origin
|
|
6872
|
+
if (query.origin === null) runs = runs.filter((r) => r.origin == null);
|
|
6873
|
+
else if (query.origin !== void 0) runs = runs.filter((r) => r.origin === query.origin);
|
|
6833
6874
|
if (query.attributes?.length) {
|
|
6834
6875
|
let candidates = null;
|
|
6835
6876
|
for (const f of query.attributes) {
|
|
@@ -6848,6 +6889,10 @@ var InMemoryStateStore = class {
|
|
|
6848
6889
|
this.lastAttributeCandidates = ids.size;
|
|
6849
6890
|
runs = runs.filter((r) => ids.has(r.id));
|
|
6850
6891
|
}
|
|
6892
|
+
return runs;
|
|
6893
|
+
}
|
|
6894
|
+
async listRuns(query) {
|
|
6895
|
+
const runs = this.matching(query);
|
|
6851
6896
|
runs.sort((a, b) => b.createdAt.getTime() - a.createdAt.getTime());
|
|
6852
6897
|
const offset = query.offset ?? 0;
|
|
6853
6898
|
const limit = query.limit ?? runs.length;
|
|
@@ -6855,6 +6900,13 @@ var InMemoryStateStore = class {
|
|
|
6855
6900
|
...r
|
|
6856
6901
|
}));
|
|
6857
6902
|
}
|
|
6903
|
+
async runFacets(query) {
|
|
6904
|
+
return mergeRunFacetRows(this.matching(query).map((run) => ({
|
|
6905
|
+
status: run.status,
|
|
6906
|
+
origin: run.origin,
|
|
6907
|
+
count: 1
|
|
6908
|
+
})));
|
|
6909
|
+
}
|
|
6858
6910
|
async listCheckpoints(runId) {
|
|
6859
6911
|
const rows = [
|
|
6860
6912
|
...this.checkpoints.values()
|
|
@@ -7000,6 +7052,7 @@ var InMemoryTransport = class {
|
|
|
7000
7052
|
eventNameOf,
|
|
7001
7053
|
eventPrefix,
|
|
7002
7054
|
eventToken,
|
|
7055
|
+
facetOrigin,
|
|
7003
7056
|
hasDurableExecutionWrappers,
|
|
7004
7057
|
heartbeatStatus,
|
|
7005
7058
|
indexWaitersByRun,
|
|
@@ -7009,6 +7062,7 @@ var InMemoryTransport = class {
|
|
|
7009
7062
|
isWorkflowControlFlowSignal,
|
|
7010
7063
|
log,
|
|
7011
7064
|
matchesAttributes,
|
|
7065
|
+
mergeRunFacetRows,
|
|
7012
7066
|
missingCapabilities,
|
|
7013
7067
|
negotiate,
|
|
7014
7068
|
normalizeAttributeRows,
|