@diagonal-hq/workflows 0.5.3 → 0.6.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.
|
@@ -7,27 +7,48 @@ import {
|
|
|
7
7
|
|
|
8
8
|
// packages/workflows/src/transaction.ts
|
|
9
9
|
async function transaction(fn) {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
10
|
+
for (; ; ) {
|
|
11
|
+
await invoke("transaction.begin", {});
|
|
12
|
+
let result;
|
|
13
|
+
try {
|
|
14
|
+
result = await fn();
|
|
15
|
+
} catch (error) {
|
|
16
|
+
if (await rollBack()) {
|
|
17
|
+
continue;
|
|
18
|
+
}
|
|
19
|
+
throw error;
|
|
20
|
+
}
|
|
21
|
+
try {
|
|
22
|
+
await invoke("transaction.commit", {});
|
|
23
|
+
} catch (error) {
|
|
24
|
+
if (isTransient(error)) {
|
|
25
|
+
continue;
|
|
26
|
+
}
|
|
27
|
+
if (error instanceof HostError && error.code === "transaction_concurrent") {
|
|
28
|
+
await rollBack();
|
|
29
|
+
}
|
|
30
|
+
throw error;
|
|
31
|
+
}
|
|
32
|
+
return result;
|
|
17
33
|
}
|
|
34
|
+
}
|
|
35
|
+
async function rollBack() {
|
|
18
36
|
try {
|
|
19
|
-
await invoke("transaction.
|
|
37
|
+
await invoke("transaction.rollback", {});
|
|
20
38
|
} catch (error) {
|
|
21
|
-
if (error
|
|
22
|
-
|
|
39
|
+
if (isTransient(error)) {
|
|
40
|
+
return true;
|
|
23
41
|
}
|
|
24
42
|
throw error;
|
|
25
43
|
}
|
|
26
|
-
return
|
|
44
|
+
return false;
|
|
45
|
+
}
|
|
46
|
+
function isTransient(error) {
|
|
47
|
+
return error instanceof HostError && error.code === "transaction_transient";
|
|
27
48
|
}
|
|
28
49
|
|
|
29
50
|
// packages/workflows/src/generated/capabilities.ts
|
|
30
|
-
var SDK_VERSION =
|
|
51
|
+
var SDK_VERSION = 68;
|
|
31
52
|
var ai = {
|
|
32
53
|
/** Ask a decisions model typed questions about some content and get labelled answers with their probabilities */
|
|
33
54
|
decide: (input) => invoke("ai.decide", input),
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { ResourceKeyWith } from "../data.js";
|
|
2
2
|
import type { ContentDocument } from "../input.js";
|
|
3
|
-
export declare const SDK_VERSION =
|
|
3
|
+
export declare const SDK_VERSION = 68;
|
|
4
4
|
export interface WorkspaceSystemFields {
|
|
5
5
|
"ai_custom_system_prompt": string | null;
|
|
6
6
|
"brand_kit": {
|
package/dist/index.js
CHANGED
package/dist/profiles/test.js
CHANGED
package/dist/transaction.d.ts
CHANGED
|
@@ -1 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Runs `fn` in one database transaction. When a concurrent write aborts the transaction, the host
|
|
3
|
+
* rolls it back and answers with `transaction_transient`, and `fn` runs again. The host limits the
|
|
4
|
+
* attempts and waits between them, so `fn` can run more than once.
|
|
5
|
+
*/
|
|
1
6
|
export declare function transaction<T>(fn: () => Promise<T>): Promise<T>;
|
package/package.json
CHANGED