@mastra/upstash 1.6.1 → 1.6.2
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/docs/SKILL.md +1 -1
- package/dist/docs/assets/SOURCE_MAP.json +7 -7
- package/dist/index.cjs +60 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +60 -2
- package/dist/index.js.map +1 -1
- package/dist/storage/domains/run-fencing.d.ts +2 -0
- package/dist/storage/domains/run-fencing.d.ts.map +1 -1
- package/dist/storage/domains/workflows/index.d.ts +9 -1
- package/dist/storage/domains/workflows/index.d.ts.map +1 -1
- package/package.json +6 -6
package/dist/docs/SKILL.md
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "1.6.
|
|
2
|
+
"version": "1.6.2",
|
|
3
3
|
"package": "@mastra/upstash",
|
|
4
4
|
"exports": {
|
|
5
5
|
"BackgroundTasksUpstash": {
|
|
@@ -10,17 +10,17 @@
|
|
|
10
10
|
"ScoresUpstash": {
|
|
11
11
|
"types": "dist/storage/domains/scores/index.d.ts",
|
|
12
12
|
"implementation": "dist/index.js",
|
|
13
|
-
"line":
|
|
13
|
+
"line": 1648
|
|
14
14
|
},
|
|
15
15
|
"StoreMemoryUpstash": {
|
|
16
16
|
"types": "dist/storage/domains/memory/index.d.ts",
|
|
17
17
|
"implementation": "dist/index.js",
|
|
18
|
-
"line":
|
|
18
|
+
"line": 628
|
|
19
19
|
},
|
|
20
20
|
"UPSTASH_PROMPT": {
|
|
21
21
|
"types": "dist/vector/prompt.d.ts",
|
|
22
22
|
"implementation": "dist/index.js",
|
|
23
|
-
"line":
|
|
23
|
+
"line": 2994
|
|
24
24
|
},
|
|
25
25
|
"UpstashServerCache": {
|
|
26
26
|
"types": "dist/cache/index.d.ts",
|
|
@@ -30,17 +30,17 @@
|
|
|
30
30
|
"UpstashStore": {
|
|
31
31
|
"types": "dist/storage/index.d.ts",
|
|
32
32
|
"implementation": "dist/index.js",
|
|
33
|
-
"line":
|
|
33
|
+
"line": 2462
|
|
34
34
|
},
|
|
35
35
|
"UpstashVector": {
|
|
36
36
|
"types": "dist/vector/index.d.ts",
|
|
37
37
|
"implementation": "dist/index.js",
|
|
38
|
-
"line":
|
|
38
|
+
"line": 2634
|
|
39
39
|
},
|
|
40
40
|
"WorkflowsUpstash": {
|
|
41
41
|
"types": "dist/storage/domains/workflows/index.d.ts",
|
|
42
42
|
"implementation": "dist/index.js",
|
|
43
|
-
"line":
|
|
43
|
+
"line": 1930
|
|
44
44
|
}
|
|
45
45
|
},
|
|
46
46
|
"modules": {}
|
package/dist/index.cjs
CHANGED
|
@@ -529,6 +529,26 @@ async function releaseRunOwnership(client, fence) {
|
|
|
529
529
|
async function getRunOwnership(client, runId) {
|
|
530
530
|
return (await evalOwner(client, READ, runId, [], Date.now())).record;
|
|
531
531
|
}
|
|
532
|
+
/** Run reads one pipeline request carries, keeping its HTTP body small. */
|
|
533
|
+
const READ_PIPELINE_BATCH_SIZE = 100;
|
|
534
|
+
/** The ownership records of `runIds`, with one pipeline request per {@link READ_PIPELINE_BATCH_SIZE} runs. */
|
|
535
|
+
async function getRunOwnerships(client, runIds) {
|
|
536
|
+
const records = /* @__PURE__ */ new Map();
|
|
537
|
+
const ids = [...new Set(runIds)];
|
|
538
|
+
for (let start = 0; start < ids.length; start += READ_PIPELINE_BATCH_SIZE) {
|
|
539
|
+
const chunk = ids.slice(start, start + READ_PIPELINE_BATCH_SIZE);
|
|
540
|
+
const now = Date.now();
|
|
541
|
+
const pipeline = client.pipeline();
|
|
542
|
+
for (const runId of chunk) pipeline.eval(READ, [runClaimKey(_mastra_core_storage.TABLE_WORKFLOW_RUN_OWNERS, runId)], []);
|
|
543
|
+
const replies = await pipeline.exec();
|
|
544
|
+
chunk.forEach((runId, i) => {
|
|
545
|
+
const raw = replies[i];
|
|
546
|
+
const record = toRunOwnershipRecord(runId, typeof raw === "string" ? JSON.parse(raw) : raw, now);
|
|
547
|
+
if (record) records.set(runId, record);
|
|
548
|
+
});
|
|
549
|
+
}
|
|
550
|
+
return records;
|
|
551
|
+
}
|
|
532
552
|
async function raiseRunFence(client, fence) {
|
|
533
553
|
const raised = await client.eval(RAISE, [runClaimKey(_mastra_core_storage.TABLE_MEMORY_RUN_FENCES, fence.runId)], [String(fence.generation), fence.ownerId]);
|
|
534
554
|
return Number(raised) === 1;
|
|
@@ -1887,6 +1907,27 @@ var ScoresUpstash = class extends _mastra_core_storage.ScoresStorage {
|
|
|
1887
1907
|
}
|
|
1888
1908
|
};
|
|
1889
1909
|
// src/storage/domains/workflows/index.ts
|
|
1910
|
+
/**
|
|
1911
|
+
* A run with its snapshot reduced to what `listWorkflowRuns({ summary: true })` returns: `status`
|
|
1912
|
+
* and `timestamp` when set, and `parentWorkflow` only when both of its IDs are non-empty strings.
|
|
1913
|
+
* A missing snapshot, or one that failed to parse and stayed a string, reduces to `{}`.
|
|
1914
|
+
*/
|
|
1915
|
+
function summarizeWorkflowRun(run) {
|
|
1916
|
+
const { status, timestamp, parentWorkflow } = run.snapshot !== null && typeof run.snapshot === "object" ? run.snapshot : {};
|
|
1917
|
+
const snapshot = {};
|
|
1918
|
+
if (status !== void 0 && status !== null) snapshot.status = status;
|
|
1919
|
+
if (timestamp !== void 0 && timestamp !== null) snapshot.timestamp = timestamp;
|
|
1920
|
+
const workflowId = parentWorkflow?.workflowId;
|
|
1921
|
+
const runId = parentWorkflow?.runId;
|
|
1922
|
+
if (typeof workflowId === "string" && workflowId !== "" && typeof runId === "string" && runId !== "") snapshot.parentWorkflow = {
|
|
1923
|
+
workflowId,
|
|
1924
|
+
runId
|
|
1925
|
+
};
|
|
1926
|
+
return {
|
|
1927
|
+
...run,
|
|
1928
|
+
snapshot
|
|
1929
|
+
};
|
|
1930
|
+
}
|
|
1890
1931
|
var WorkflowsUpstash = class extends _mastra_core_storage.WorkflowsStorage {
|
|
1891
1932
|
client;
|
|
1892
1933
|
#db;
|
|
@@ -1966,6 +2007,19 @@ var WorkflowsUpstash = class extends _mastra_core_storage.WorkflowsStorage {
|
|
|
1966
2007
|
throw this.#ownershipError("GET_RUN_OWNERSHIP", runId, error);
|
|
1967
2008
|
}
|
|
1968
2009
|
}
|
|
2010
|
+
/** Reads the records with one pipeline request per hundred runs. */
|
|
2011
|
+
async getRunOwnerships({ runIds }) {
|
|
2012
|
+
try {
|
|
2013
|
+
return await getRunOwnerships(this.client, runIds);
|
|
2014
|
+
} catch (error) {
|
|
2015
|
+
throw new _mastra_core_error.MastraError({
|
|
2016
|
+
id: (0, _mastra_core_storage.createStorageErrorId)("UPSTASH", "GET_RUN_OWNERSHIPS", "FAILED"),
|
|
2017
|
+
domain: _mastra_core_error.ErrorDomain.STORAGE,
|
|
2018
|
+
category: _mastra_core_error.ErrorCategory.THIRD_PARTY,
|
|
2019
|
+
details: { runCount: runIds.length }
|
|
2020
|
+
}, error);
|
|
2021
|
+
}
|
|
2022
|
+
}
|
|
1969
2023
|
async getWorkflowRunRecord({ namespace, runId, resourceId, workflowName }) {
|
|
1970
2024
|
if (workflowName) {
|
|
1971
2025
|
const keyVariants = [...resourceId ? [{
|
|
@@ -2321,7 +2375,11 @@ var WorkflowsUpstash = class extends _mastra_core_storage.WorkflowsStorage {
|
|
|
2321
2375
|
}, error);
|
|
2322
2376
|
}
|
|
2323
2377
|
}
|
|
2324
|
-
|
|
2378
|
+
/**
|
|
2379
|
+
* Lists runs newest first. With `summary`, each snapshot keeps only its status, timestamp and
|
|
2380
|
+
* parent run; the full snapshots are still read from Upstash.
|
|
2381
|
+
*/
|
|
2382
|
+
async listWorkflowRuns({ workflowName, fromDate, toDate, perPage, page, resourceId, status, summary } = {}) {
|
|
2325
2383
|
try {
|
|
2326
2384
|
if (page !== void 0 && page < 0) throw new _mastra_core_error.MastraError({
|
|
2327
2385
|
id: (0, _mastra_core_storage.createStorageErrorId)("UPSTASH", "LIST_WORKFLOW_RUNS", "INVALID_PAGE"),
|
|
@@ -2359,7 +2417,7 @@ var WorkflowsUpstash = class extends _mastra_core_storage.WorkflowsStorage {
|
|
|
2359
2417
|
runs = runs.slice(offset, offset + normalizedPerPage);
|
|
2360
2418
|
}
|
|
2361
2419
|
return {
|
|
2362
|
-
runs,
|
|
2420
|
+
runs: summary ? runs.map(summarizeWorkflowRun) : runs,
|
|
2363
2421
|
total
|
|
2364
2422
|
};
|
|
2365
2423
|
} catch (error) {
|