zitejs 0.10.0-start.2 → 0.10.0-start.20
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/cjs/auth/index.d.ts +2 -2
- package/dist/cjs/auth/index.js +6 -0
- package/dist/cjs/auth/index.test.js +30 -0
- package/dist/cjs/auth/previewClaim.d.ts +7 -0
- package/dist/cjs/auth/previewClaim.js +16 -0
- package/dist/cjs/backend/index.d.ts +121 -3
- package/dist/cjs/backend/index.test.js +58 -0
- package/dist/cjs/bundle/index.d.ts +8 -0
- package/dist/cjs/bundle/index.js +9 -8
- package/dist/cjs/check/index.d.ts +45 -1
- package/dist/cjs/check/index.js +198 -109
- package/dist/cjs/check/start/problem.d.ts +11 -0
- package/dist/cjs/check/start/problem.js +5 -0
- package/dist/cjs/check/start/routeTree.d.ts +9 -0
- package/dist/cjs/check/start/routeTree.js +111 -0
- package/dist/cjs/check/start/sourceRules.d.ts +8 -0
- package/dist/cjs/check/start/sourceRules.js +1110 -0
- package/dist/cjs/check/start/tsgo.d.ts +2 -0
- package/dist/cjs/check/start/tsgo.js +35 -0
- package/dist/cjs/cli.js +1 -1
- package/dist/cjs/client/index.d.ts +24 -0
- package/dist/cjs/dev/index.js +14 -4
- package/dist/cjs/integrations/rules.d.ts +13 -0
- package/dist/cjs/integrations/rules.js +29 -0
- package/dist/cjs/integrations/rules.test.js +1 -0
- package/dist/cjs/internal/appMode.d.ts +3 -0
- package/dist/cjs/internal/appMode.js +15 -0
- package/dist/cjs/runtime/index.d.ts +13 -13
- package/dist/cjs/start/entries.d.ts +10 -4
- package/dist/cjs/start/entries.js +23 -6
- package/dist/cjs/steps/index.d.ts +78 -0
- package/dist/cjs/steps/index.js +507 -0
- package/dist/cjs/steps/index.test.d.ts +1 -0
- package/dist/cjs/steps/index.test.js +635 -0
- package/dist/cjs/sync/index.js +2 -1
- package/dist/cjs/sync/lib.d.ts +10 -3
- package/dist/cjs/sync/lib.js +35 -21
- package/dist/cjs/sync/lib.test.js +106 -36
- package/dist/cjs/types/fields.d.ts +8 -1
- package/dist/cjs/types/fields.js +7 -1
- package/dist/cjs/types/tables.d.ts +16 -0
- package/dist/cjs/upload/index.js +12 -2
- package/dist/cjs/upload/index.test.js +39 -0
- package/dist/cjs/vite/index.js +8 -3
- package/dist/cjs/vite/index.test.js +10 -2
- package/dist/esm/auth/index.d.ts +2 -2
- package/dist/esm/auth/index.js +6 -0
- package/dist/esm/auth/index.test.js +30 -0
- package/dist/esm/auth/previewClaim.d.ts +7 -0
- package/dist/esm/auth/previewClaim.js +12 -0
- package/dist/esm/backend/index.d.ts +121 -3
- package/dist/esm/backend/index.test.js +58 -0
- package/dist/esm/bundle/index.d.ts +8 -0
- package/dist/esm/bundle/index.js +8 -8
- package/dist/esm/check/index.d.ts +45 -1
- package/dist/esm/check/index.js +198 -113
- package/dist/esm/check/start/problem.d.ts +11 -0
- package/dist/esm/check/start/problem.js +1 -0
- package/dist/esm/check/start/routeTree.d.ts +9 -0
- package/dist/esm/check/start/routeTree.js +70 -0
- package/dist/esm/check/start/sourceRules.d.ts +8 -0
- package/dist/esm/check/start/sourceRules.js +1107 -0
- package/dist/esm/check/start/tsgo.d.ts +2 -0
- package/dist/esm/check/start/tsgo.js +29 -0
- package/dist/esm/cli.js +1 -1
- package/dist/esm/client/index.d.ts +24 -0
- package/dist/esm/dev/index.js +16 -6
- package/dist/esm/integrations/rules.d.ts +13 -0
- package/dist/esm/integrations/rules.js +29 -0
- package/dist/esm/integrations/rules.test.js +1 -0
- package/dist/esm/internal/appMode.d.ts +3 -0
- package/dist/esm/internal/appMode.js +10 -0
- package/dist/esm/runtime/index.d.ts +13 -13
- package/dist/esm/start/aiUsage.d.ts +23 -0
- package/dist/esm/start/aiUsage.js +146 -0
- package/dist/esm/start/airtable/arrayFields.d.ts +10 -0
- package/dist/esm/start/airtable/arrayFields.js +30 -0
- package/dist/esm/start/airtable/dispatch.d.ts +54 -0
- package/dist/esm/start/airtable/dispatch.js +483 -0
- package/dist/esm/start/airtable/formulas.d.ts +70 -0
- package/dist/esm/start/airtable/formulas.js +258 -0
- package/dist/esm/start/airtable/index.d.ts +8 -0
- package/dist/esm/start/airtable/index.js +54 -0
- package/dist/esm/start/authHooks.d.ts +7 -0
- package/dist/esm/start/authHooks.js +10 -0
- package/dist/esm/start/authHooksModule.d.ts +1 -0
- package/dist/esm/start/authHooksModule.js +3 -0
- package/dist/esm/start/clientErrorMessage.test.d.ts +1 -0
- package/dist/esm/start/clientErrorMessage.test.js +105 -0
- package/dist/esm/start/credentials.d.ts +2 -0
- package/dist/esm/start/credentials.js +2 -0
- package/dist/esm/start/data/baseRunner.d.ts +92 -0
- package/dist/esm/start/data/baseRunner.js +83 -0
- package/dist/esm/start/data/dispatch.d.ts +16 -0
- package/dist/esm/start/data/dispatch.js +198 -0
- package/dist/esm/start/data/index.d.ts +15 -0
- package/dist/esm/start/data/index.js +58 -0
- package/dist/esm/start/data/sqlNameMappings.d.ts +58 -0
- package/dist/esm/start/data/sqlNameMappings.js +92 -0
- package/dist/esm/start/data/transformations.d.ts +97 -0
- package/dist/esm/start/data/transformations.js +262 -0
- package/dist/esm/start/data/types.d.ts +91 -0
- package/dist/esm/start/data/types.js +14 -0
- package/dist/esm/start/describe.d.ts +35 -5
- package/dist/esm/start/describe.js +74 -22
- package/dist/esm/start/entries.d.ts +10 -4
- package/dist/esm/start/entries.js +21 -5
- package/dist/esm/start/errors.d.ts +63 -0
- package/dist/esm/start/errors.js +146 -0
- package/dist/esm/start/errors.test.d.ts +1 -0
- package/dist/esm/start/errors.test.js +23 -0
- package/dist/esm/start/factories.test-d.d.ts +1 -0
- package/dist/esm/start/factories.test-d.js +20 -0
- package/dist/esm/start/index.d.ts +32 -27
- package/dist/esm/start/index.js +77 -47
- package/dist/esm/start/instance.d.ts +4 -4
- package/dist/esm/start/instance.js +54 -11
- package/dist/esm/start/outbound.d.ts +11 -0
- package/dist/esm/start/outbound.js +398 -0
- package/dist/esm/start/previewClaim.d.ts +7 -0
- package/dist/esm/start/previewClaim.js +23 -0
- package/dist/esm/start/problems.js +1 -1
- package/dist/esm/start/quiet.d.ts +2 -0
- package/dist/esm/start/quiet.js +27 -0
- package/dist/esm/start/redactSecrets.d.ts +15 -0
- package/dist/esm/start/redactSecrets.js +154 -0
- package/dist/esm/start/redactSecrets.test.d.ts +1 -0
- package/dist/esm/start/redactSecrets.test.js +151 -0
- package/dist/esm/start/registration.d.ts +13 -0
- package/dist/esm/start/registration.js +21 -0
- package/dist/esm/start/registrationHash.d.ts +22 -0
- package/dist/esm/start/registrationHash.js +470 -0
- package/dist/esm/start/router.d.ts +18 -4
- package/dist/esm/start/router.js +134 -11
- package/dist/esm/start/runLog.d.ts +7 -4
- package/dist/esm/start/runLog.js +64 -6
- package/dist/esm/start/scope.d.ts +2 -2
- package/dist/esm/start/server.d.ts +40 -36
- package/dist/esm/start/server.js +320 -48
- package/dist/esm/start/steps.d.ts +28 -0
- package/dist/esm/start/steps.js +97 -0
- package/dist/esm/start/types.d.ts +178 -5
- package/dist/esm/start/version.d.ts +1 -0
- package/dist/esm/start/version.js +2 -0
- package/dist/esm/start/vite.js +88 -11
- package/dist/esm/start/worker.d.ts +6 -0
- package/dist/esm/start/worker.js +12 -0
- package/dist/esm/start/workflow.d.ts +42 -12
- package/dist/esm/start/workflow.js +3 -3
- package/dist/esm/start/workflow.test-d.js +41 -8
- package/dist/esm/start/workflowModules.js +1 -1
- package/dist/esm/start/workflowRun.d.ts +21 -8
- package/dist/esm/start/workflowRun.js +29 -8
- package/dist/esm/steps/index.d.ts +78 -0
- package/dist/esm/steps/index.js +502 -0
- package/dist/esm/steps/index.test.d.ts +1 -0
- package/dist/esm/steps/index.test.js +633 -0
- package/dist/esm/sync/index.js +2 -1
- package/dist/esm/sync/lib.d.ts +10 -3
- package/dist/esm/sync/lib.js +35 -21
- package/dist/esm/sync/lib.test.js +106 -36
- package/dist/esm/types/fields.d.ts +8 -1
- package/dist/esm/types/fields.js +6 -0
- package/dist/esm/types/tables.d.ts +16 -0
- package/dist/esm/upload/index.js +12 -2
- package/dist/esm/upload/index.test.js +39 -0
- package/dist/esm/vite/index.js +8 -3
- package/dist/esm/vite/index.test.js +10 -2
- package/package.json +37 -16
- package/dist/cjs/start/problems.d.ts +0 -19
- package/dist/cjs/start/problems.js +0 -11
|
@@ -1,24 +1,57 @@
|
|
|
1
1
|
import { describe, expectTypeOf, it } from "vitest";
|
|
2
|
-
import {
|
|
3
|
-
describe("
|
|
2
|
+
import { createAutomation } from "./workflow.js";
|
|
3
|
+
describe("createAutomation handler args", () => {
|
|
4
4
|
it("gives a schedule no trigger", () => {
|
|
5
|
-
|
|
5
|
+
createAutomation({ schedule: { scheduleType: "oneTime", fireAt: "2026-10-10T03:00:00Z", timezone: "UTC" } }).handler((args) => {
|
|
6
6
|
expectTypeOf(args).toEqualTypeOf();
|
|
7
7
|
});
|
|
8
8
|
});
|
|
9
9
|
it("types the trigger by the kind it declares", () => {
|
|
10
|
-
|
|
10
|
+
createAutomation({ trigger: { every: "5m" } }).handler(({ trigger }) => {
|
|
11
11
|
expectTypeOf(trigger).toEqualTypeOf();
|
|
12
12
|
});
|
|
13
|
-
|
|
13
|
+
createAutomation({ trigger: { integration: "slack", events: ["message.channels"] } }).handler(({ trigger }) => {
|
|
14
14
|
expectTypeOf(trigger).toEqualTypeOf();
|
|
15
15
|
});
|
|
16
|
-
|
|
16
|
+
createAutomation({
|
|
17
|
+
trigger: { integration: "asana", subscribe: async () => ({ externalId: "w1" }), unsubscribe: async () => { } },
|
|
18
|
+
}).handler(({ trigger }) => {
|
|
17
19
|
expectTypeOf(trigger).toEqualTypeOf();
|
|
18
20
|
});
|
|
19
21
|
});
|
|
22
|
+
it("registers a provider trigger with subscribe", () => {
|
|
23
|
+
// @ts-expect-error nothing would register it with the provider
|
|
24
|
+
createAutomation({ trigger: { integration: "asana" } });
|
|
25
|
+
createAutomation({
|
|
26
|
+
trigger: {
|
|
27
|
+
integration: "github",
|
|
28
|
+
subscribe: (input) => {
|
|
29
|
+
expectTypeOf(input.notificationUrl).toEqualTypeOf();
|
|
30
|
+
return { externalId: "1", secret: input.secret };
|
|
31
|
+
},
|
|
32
|
+
},
|
|
33
|
+
});
|
|
34
|
+
});
|
|
35
|
+
it("takes no database or form trigger yet, with or without subscribe", () => {
|
|
36
|
+
const subscribe = async () => ({ externalId: "w1" });
|
|
37
|
+
// @ts-expect-error a Start automation can't take a database trigger yet
|
|
38
|
+
createAutomation({ trigger: { table: "orders", on: ["created"], subscribe } });
|
|
39
|
+
// @ts-expect-error nor a form trigger
|
|
40
|
+
createAutomation({ trigger: { form: "Intake", on: ["submitted"], subscribe } });
|
|
41
|
+
});
|
|
42
|
+
it("needs neither when only schedules added at runtime run it", () => {
|
|
43
|
+
createAutomation({ description: "Sends one reminder" }).handler((args) => {
|
|
44
|
+
expectTypeOf(args).toEqualTypeOf();
|
|
45
|
+
});
|
|
46
|
+
});
|
|
47
|
+
it("gives every workflow step.run, typed by what its function returns", () => {
|
|
48
|
+
createAutomation({ trigger: { every: "5m" } }).handler(async ({ step }) => {
|
|
49
|
+
expectTypeOf(await step.run("load", async () => ({ id: 7 }))).toEqualTypeOf();
|
|
50
|
+
expectTypeOf(await step.run("count", () => 3)).toEqualTypeOf();
|
|
51
|
+
});
|
|
52
|
+
});
|
|
20
53
|
it("takes a schedule or a trigger, not both", () => {
|
|
21
|
-
// @ts-expect-error
|
|
22
|
-
|
|
54
|
+
// @ts-expect-error an automation runs on one or the other
|
|
55
|
+
createAutomation({ schedule: { scheduleType: "oneTime", fireAt: "x", timezone: "UTC" }, trigger: { every: "5m" } });
|
|
23
56
|
});
|
|
24
57
|
});
|
|
@@ -1,20 +1,26 @@
|
|
|
1
|
-
import { type
|
|
1
|
+
import { type StepLog } from "./steps.js";
|
|
2
|
+
import { type Automation } from "./workflow.js";
|
|
2
3
|
export type TriggerReport = {
|
|
3
4
|
handled: string[];
|
|
4
5
|
cursor?: string;
|
|
5
6
|
};
|
|
6
|
-
|
|
7
|
+
type StepsRan = {
|
|
8
|
+
steps?: StepLog[];
|
|
9
|
+
};
|
|
10
|
+
export type WorkflowRunResult = ({
|
|
7
11
|
ok: true;
|
|
8
12
|
output: unknown;
|
|
9
13
|
trigger?: TriggerReport;
|
|
10
|
-
} | {
|
|
14
|
+
} & StepsRan) | ({
|
|
11
15
|
ok: false;
|
|
12
16
|
error: {
|
|
13
17
|
code: string;
|
|
14
18
|
message: string;
|
|
15
19
|
};
|
|
16
20
|
trigger?: TriggerReport;
|
|
17
|
-
|
|
21
|
+
failedStep?: string;
|
|
22
|
+
} & StepsRan);
|
|
23
|
+
type SdkCall = (integrationId: string, className: string, methodName: string, params: unknown) => Promise<unknown>;
|
|
18
24
|
/**
|
|
19
25
|
* Splits the platform's state out of the input. A poll or a provider delivery
|
|
20
26
|
* with a cursor gets `seen`, `handled` and `advance`. Handled ids are reported
|
|
@@ -22,7 +28,7 @@ export type WorkflowRunResult = {
|
|
|
22
28
|
* the staged cursor only on success. Only ids the incoming `seen` lacked are
|
|
23
29
|
* reported: billing reads an empty list as a run that found nothing new.
|
|
24
30
|
*/
|
|
25
|
-
export declare function triggerContext(workflow:
|
|
31
|
+
export declare function triggerContext(workflow: Automation, rawInput: unknown): {
|
|
26
32
|
input: unknown;
|
|
27
33
|
trigger?: undefined;
|
|
28
34
|
report?: undefined;
|
|
@@ -67,14 +73,21 @@ export declare function triggerContext(workflow: Workflow, rawInput: unknown): {
|
|
|
67
73
|
};
|
|
68
74
|
report: (succeeded: boolean) => TriggerReport;
|
|
69
75
|
};
|
|
70
|
-
/**
|
|
71
|
-
|
|
76
|
+
/**
|
|
77
|
+
* Runs the handler in a workflow access scope: no user, and data calls allowed.
|
|
78
|
+
* A resumed run replays the steps its first attempt saved.
|
|
79
|
+
*/
|
|
80
|
+
export declare function runWorkflow(workflow: Automation, rawInput: unknown, { resuming, call }?: {
|
|
81
|
+
resuming?: boolean;
|
|
82
|
+
call?: SdkCall;
|
|
83
|
+
}): Promise<WorkflowRunResult>;
|
|
72
84
|
export type LoadedWorkflow = {
|
|
73
85
|
id: string;
|
|
74
86
|
file: string;
|
|
75
|
-
workflow:
|
|
87
|
+
workflow: Automation;
|
|
76
88
|
};
|
|
77
89
|
/** Every exported workflow in the app, by export name. */
|
|
78
90
|
export declare function loadWorkflows(modules?: Record<string, () => Promise<Record<string, unknown>>>): Promise<LoadedWorkflow[]>;
|
|
79
91
|
/** The input as the run log keeps it: a trigger's `seen` list can hold thousands of ids. */
|
|
80
92
|
export declare const loggedInput: (rawInput: unknown) => unknown;
|
|
93
|
+
export {};
|
|
@@ -3,8 +3,15 @@
|
|
|
3
3
|
// runner's schedules, polls and provider deliveries work unchanged.
|
|
4
4
|
import { errorOf } from "./runLog.js";
|
|
5
5
|
import { runInScope } from "./scope.js";
|
|
6
|
-
import {
|
|
6
|
+
import { createSteps } from "./steps.js";
|
|
7
|
+
import { isAutomation } from "./workflow.js";
|
|
7
8
|
import { workflowModules } from "./workflowModules.js";
|
|
9
|
+
const platformCall = (...args) => {
|
|
10
|
+
const call = globalThis.__wrapSdkCall;
|
|
11
|
+
if (!call)
|
|
12
|
+
throw new Error("The Zite platform binding is missing");
|
|
13
|
+
return call(...args);
|
|
14
|
+
};
|
|
8
15
|
const asRecord = (value) => value && typeof value === "object" && !Array.isArray(value) ? value : null;
|
|
9
16
|
const idOf = (id) => {
|
|
10
17
|
if (typeof id !== "string" && typeof id !== "number")
|
|
@@ -23,7 +30,8 @@ const idOf = (id) => {
|
|
|
23
30
|
*/
|
|
24
31
|
export function triggerContext(workflow, rawInput) {
|
|
25
32
|
const raw = asRecord(rawInput);
|
|
26
|
-
|
|
33
|
+
// `__cron` stays in the input, as on classic: scheduled code reads its scheduleId and scheduledAt there.
|
|
34
|
+
const { __poll, __webhook, ...input } = raw ?? {};
|
|
27
35
|
const declared = workflow.config.trigger;
|
|
28
36
|
if (!declared)
|
|
29
37
|
return { input: raw ? input : rawInput };
|
|
@@ -70,16 +78,29 @@ export function triggerContext(workflow, rawInput) {
|
|
|
70
78
|
});
|
|
71
79
|
return { input, trigger, report };
|
|
72
80
|
}
|
|
73
|
-
/**
|
|
74
|
-
|
|
81
|
+
/**
|
|
82
|
+
* Runs the handler in a workflow access scope: no user, and data calls allowed.
|
|
83
|
+
* A resumed run replays the steps its first attempt saved.
|
|
84
|
+
*/
|
|
85
|
+
export async function runWorkflow(workflow, rawInput, { resuming = false, call = platformCall } = {}) {
|
|
75
86
|
const { input, trigger, report } = triggerContext(workflow, rawInput);
|
|
76
|
-
const
|
|
87
|
+
const steps = createSteps({ call, resuming });
|
|
88
|
+
const args = { input, step: steps.step, ...(trigger ? { trigger } : {}) };
|
|
89
|
+
const ran = () => (steps.log.length > 0 ? { steps: steps.log } : {});
|
|
77
90
|
try {
|
|
78
91
|
const output = await runInScope({ kind: "workflow", user: null }, () => workflow.handler(args));
|
|
79
|
-
return { ok: true, output, ...(report ? { trigger: report(true) } : {}) };
|
|
92
|
+
return { ok: true, output, ...(report ? { trigger: report(true) } : {}), ...ran() };
|
|
80
93
|
}
|
|
81
94
|
catch (error) {
|
|
82
|
-
|
|
95
|
+
await steps.settle();
|
|
96
|
+
const failedStep = steps.failedStep();
|
|
97
|
+
return {
|
|
98
|
+
ok: false,
|
|
99
|
+
error: errorOf(error),
|
|
100
|
+
...(report ? { trigger: report(false) } : {}),
|
|
101
|
+
...(failedStep !== undefined ? { failedStep } : {}),
|
|
102
|
+
...ran(),
|
|
103
|
+
};
|
|
83
104
|
}
|
|
84
105
|
}
|
|
85
106
|
/** Every exported workflow in the app, by export name. */
|
|
@@ -87,7 +108,7 @@ export async function loadWorkflows(modules = workflowModules) {
|
|
|
87
108
|
const found = [];
|
|
88
109
|
for (const [file, load] of Object.entries(modules)) {
|
|
89
110
|
for (const [id, value] of Object.entries(await load()))
|
|
90
|
-
if (
|
|
111
|
+
if (isAutomation(value))
|
|
91
112
|
found.push({ id, file, workflow: value });
|
|
92
113
|
}
|
|
93
114
|
return found;
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import type { ZiteStep } from "../backend/index.js";
|
|
2
|
+
export declare const STEP_FAILURE_MEMO_KEY = "__ziteStepError";
|
|
3
|
+
export declare const STEP_FAILED_STEP_KEY = "__ziteFailedStep";
|
|
4
|
+
export declare const STEP_RESULT_MAX_BYTES: number;
|
|
5
|
+
export declare const STEP_SLEEP_MAX_MS: number;
|
|
6
|
+
export declare const STEP_DEFAULT_RETRIES = 3;
|
|
7
|
+
export declare const STEP_MAX_RETRIES = 10;
|
|
8
|
+
/** Why a durable call stops short. A retry outranks the other two. */
|
|
9
|
+
export type StepStop = {
|
|
10
|
+
kind: "retry";
|
|
11
|
+
name: string;
|
|
12
|
+
attempt: number;
|
|
13
|
+
error: unknown;
|
|
14
|
+
} | {
|
|
15
|
+
kind: "sleep";
|
|
16
|
+
name: string;
|
|
17
|
+
wakeAt: string;
|
|
18
|
+
} | {
|
|
19
|
+
kind: "step";
|
|
20
|
+
name: string;
|
|
21
|
+
};
|
|
22
|
+
/** A stop that isn't a failure: the run goes on at a wake time, or at once. */
|
|
23
|
+
export type StepSuspension = {
|
|
24
|
+
kind: "sleep";
|
|
25
|
+
name: string;
|
|
26
|
+
wakeAt: string;
|
|
27
|
+
} | {
|
|
28
|
+
kind: "step";
|
|
29
|
+
name: string;
|
|
30
|
+
};
|
|
31
|
+
/** A stop to try a step again: each failed step's next try, in the next call. */
|
|
32
|
+
export type StepRetry = {
|
|
33
|
+
step: string;
|
|
34
|
+
attempt: number;
|
|
35
|
+
attempts: Record<string, number>;
|
|
36
|
+
};
|
|
37
|
+
export type StepEventStatus = "ran" | "memoized" | "failed" | "sleeping" | "skipped";
|
|
38
|
+
export type StepRuntimeOptions = {
|
|
39
|
+
/** The run's saved steps by name, from earlier calls; filled in as steps save. */
|
|
40
|
+
memos: Record<string, unknown>;
|
|
41
|
+
/** A durable call may stop at a step for its orchestrator to call it again. */
|
|
42
|
+
durable: boolean;
|
|
43
|
+
/** Outside a durable call, what a sleep does: an editor test skips it, an app's request refuses it. */
|
|
44
|
+
sleeps?: "skip" | "refuse";
|
|
45
|
+
/** In a durable call, how long it starts new steps for. */
|
|
46
|
+
budgetMs?: number;
|
|
47
|
+
/**
|
|
48
|
+
* How long after the call starts `settle` waits for steps still working.
|
|
49
|
+
* A step past it runs again in the next call. Four minutes by default, so
|
|
50
|
+
* the call answers inside a five-minute request timeout.
|
|
51
|
+
*/
|
|
52
|
+
deadlineMs?: number;
|
|
53
|
+
/** Which try each step that failed in an earlier call is on; others are on their first. */
|
|
54
|
+
attempts?: Record<string, number>;
|
|
55
|
+
/** Saves a step's result, or its final failure. Throws when it can't. */
|
|
56
|
+
save: (name: string, value: unknown, durationMs: number) => Promise<unknown>;
|
|
57
|
+
onEvent?: (name: string, status: StepEventStatus, durationMs?: number, extra?: Record<string, unknown>) => void;
|
|
58
|
+
/** Marks a failed save as the platform's failure rather than the app's. */
|
|
59
|
+
onPlatformFault?: (error: Error) => void;
|
|
60
|
+
now?: () => number;
|
|
61
|
+
};
|
|
62
|
+
export type StepRuntime = {
|
|
63
|
+
step: ZiteStep;
|
|
64
|
+
/** Resolves at the call's first stop. */
|
|
65
|
+
stopped: Promise<void>;
|
|
66
|
+
stop(): StepStop | undefined;
|
|
67
|
+
suspension(): StepSuspension | undefined;
|
|
68
|
+
retry(): StepRetry | undefined;
|
|
69
|
+
/** How many steps this call saved, sleeps included. */
|
|
70
|
+
saved(): number;
|
|
71
|
+
/**
|
|
72
|
+
* Waits for steps still doing work to save, including ones they start, but
|
|
73
|
+
* not for one stuck behind a stop, nor past the deadline.
|
|
74
|
+
*/
|
|
75
|
+
settle(): Promise<void>;
|
|
76
|
+
};
|
|
77
|
+
export declare const isStepFailureMemo: (memo: unknown) => boolean;
|
|
78
|
+
export declare function createStepRuntime(options: StepRuntimeOptions): StepRuntime;
|