@lmzhen/dsh-evolution-state-domain 0.3.17 → 0.3.18
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/lib/index.js +14 -0
- package/package.json +3 -3
package/lib/index.js
CHANGED
|
@@ -104,6 +104,20 @@ function apply(ctx) {
|
|
|
104
104
|
async saveCuratorState(record) {
|
|
105
105
|
await (await ensure()).table("curator_state").put("primary", record);
|
|
106
106
|
},
|
|
107
|
+
async transactCuratorState(task) {
|
|
108
|
+
const table = (await ensure()).table("curator_state");
|
|
109
|
+
try {
|
|
110
|
+
await table.update("primary", (current) => task(current) ?? current);
|
|
111
|
+
} catch (error) {
|
|
112
|
+
if (error instanceof DomainError && error.code === "missing-key") {
|
|
113
|
+
const next = task(null);
|
|
114
|
+
if (next !== null) await table.put("primary", next);
|
|
115
|
+
else await table.delete("primary");
|
|
116
|
+
return;
|
|
117
|
+
}
|
|
118
|
+
throw error;
|
|
119
|
+
}
|
|
120
|
+
},
|
|
107
121
|
async listPending(status = "pending") {
|
|
108
122
|
return [...(await ensure()).table("pending").entries()].map(([, value]) => value).filter((record) => record.status === status);
|
|
109
123
|
},
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lmzhen/dsh-evolution-state-domain",
|
|
3
3
|
"description": "storage-domain provider for evolution state (community build)",
|
|
4
|
-
"version": "0.3.
|
|
4
|
+
"version": "0.3.18",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
7
7
|
},
|
|
@@ -38,11 +38,11 @@
|
|
|
38
38
|
"@deepseek-ai/dsh-invariants": "^0.1.1-rc.2",
|
|
39
39
|
"@deepseek-ai/cordis": "^4.0.1",
|
|
40
40
|
"@deepseek-ai/dsh-storage-domain": "^0.1.1-rc.2",
|
|
41
|
-
"@lmzhen/dsh-evolution-state-storage": "^0.3.
|
|
41
|
+
"@lmzhen/dsh-evolution-state-storage": "^0.3.18"
|
|
42
42
|
},
|
|
43
43
|
"devDependencies": {
|
|
44
44
|
"@deepseek-ai/dsh-invariants": "^0.1.1-rc.2",
|
|
45
45
|
"@deepseek-ai/dsh-storage-domain": "^0.1.1-rc.2",
|
|
46
|
-
"@lmzhen/dsh-evolution-state-storage": "^0.3.
|
|
46
|
+
"@lmzhen/dsh-evolution-state-storage": "^0.3.18"
|
|
47
47
|
}
|
|
48
48
|
}
|