yieldstar 0.5.0 → 0.6.1
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/README.md +43 -52
- package/dist/exports/errors.d.ts.map +1 -1
- package/dist/exports/sdk-http.d.ts +8 -0
- package/dist/exports/sdk-http.d.ts.map +1 -1
- package/dist/exports/sdk-local.d.ts +19 -2
- package/dist/exports/sdk-local.d.ts.map +1 -1
- package/dist/exports/workflow.d.ts +14 -2
- package/dist/exports/workflow.d.ts.map +1 -1
- package/dist/index.d.ts +4 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +664 -214
- package/dist/internal/effect-call.d.ts +60 -0
- package/dist/internal/effect-call.d.ts.map +1 -0
- package/dist/internal/runtime-call.d.ts +39 -0
- package/dist/internal/runtime-call.d.ts.map +1 -0
- package/dist/internal/serialise.d.ts.map +1 -1
- package/dist/internal/step-record.d.ts +13 -0
- package/dist/internal/step-record.d.ts.map +1 -0
- package/dist/internal/step-runner.d.ts +77 -14
- package/dist/internal/step-runner.d.ts.map +1 -1
- package/package.json +2 -3
- package/src/exports/errors.ts +4 -0
- package/src/exports/sdk-http.ts +60 -27
- package/src/exports/sdk-local.ts +41 -15
- package/src/exports/workflow.ts +157 -101
- package/src/index.ts +34 -2
- package/src/internal/effect-call.ts +217 -0
- package/src/internal/runtime-call.ts +95 -0
- package/src/internal/step-record.ts +110 -0
- package/src/internal/step-runner.ts +515 -191
- package/src/internal/serialise.ts +0 -47
- package/tsconfig.tsbuildinfo +0 -1
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
StepDelay,
|
|
3
|
-
StepError,
|
|
4
|
-
StepResult,
|
|
5
|
-
StepResponse,
|
|
6
|
-
StepStoreWait,
|
|
7
|
-
WorkflowResult,
|
|
8
|
-
} from "@yieldstar/core";
|
|
9
|
-
import { isErrorLike, serializeError, deserializeError } from "serialize-error";
|
|
10
|
-
|
|
11
|
-
export function serializeStepResponse(data: StepResponse): string {
|
|
12
|
-
const replaceErrors = (key: string, value: any) => {
|
|
13
|
-
if (value instanceof Error) {
|
|
14
|
-
return serializeError(value);
|
|
15
|
-
}
|
|
16
|
-
return value;
|
|
17
|
-
};
|
|
18
|
-
|
|
19
|
-
return JSON.stringify(data, replaceErrors);
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
export function deserializeStepResponse(jsonString: string): StepResponse {
|
|
23
|
-
const reviveErrors = (key: string, value: any) => {
|
|
24
|
-
if (isErrorLike(value)) {
|
|
25
|
-
return deserializeError(value);
|
|
26
|
-
}
|
|
27
|
-
return value;
|
|
28
|
-
};
|
|
29
|
-
|
|
30
|
-
const stepResponse = JSON.parse(jsonString, reviveErrors);
|
|
31
|
-
|
|
32
|
-
switch (stepResponse.type) {
|
|
33
|
-
case "step-error":
|
|
34
|
-
const { err, ...params } = stepResponse;
|
|
35
|
-
return new StepError(stepResponse.err, params);
|
|
36
|
-
case "step-delay":
|
|
37
|
-
return new StepDelay(stepResponse.resumeIn);
|
|
38
|
-
case "step-result":
|
|
39
|
-
return new StepResult(stepResponse.result);
|
|
40
|
-
case "store-wait":
|
|
41
|
-
return new StepStoreWait();
|
|
42
|
-
case "workflow-result":
|
|
43
|
-
return new WorkflowResult(stepResponse.result);
|
|
44
|
-
default:
|
|
45
|
-
throw new Error("Unknown step result type: " + stepResponse.type);
|
|
46
|
-
}
|
|
47
|
-
}
|