@lovable.dev/workflows-sdk 0.0.0-dev.1 → 0.0.0-dev.11
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 +507 -28
- package/dist/duplicate-ids-CSzTGBYE.js +115 -0
- package/dist/durable-ids-LsygHSZC.js +17 -0
- package/dist/generate-DkZJkfZ1.js +235 -0
- package/dist/{graph-extract-SXSdcip0.js → graph-CPDci8jW.js} +117 -18
- package/dist/index.d.ts +195 -21
- package/dist/index.js +663 -3
- package/dist/vite.d.ts +18 -5
- package/dist/vite.js +303 -9
- package/package.json +12 -7
- package/dist/manifest-DYEhsHr3.js +0 -114
package/dist/index.d.ts
CHANGED
|
@@ -1,35 +1,94 @@
|
|
|
1
|
-
import { AnyWorkflowDefinition, AnyWorkflowDefinition as AnyWorkflowDefinition$1, Ctx, StepContext, StepOptions, WorkflowDefinition, WorkflowInput, WorkflowInput as WorkflowInput$1, WorkflowOutput, WorkflowState, createMiddleware, createWorkflow } from "@tanstack/workflow-core";
|
|
2
|
-
|
|
1
|
+
import { AnyWorkflowDefinition, AnyWorkflowDefinition as AnyWorkflowDefinition$1, Ctx, RunStore, StepContext, StepOptions, WorkflowDefinition, WorkflowEvent, WorkflowInput, WorkflowInput as WorkflowInput$1, WorkflowOutput, WorkflowState, createMiddleware, createWorkflow } from "@tanstack/workflow-core";
|
|
2
|
+
import "typescript";
|
|
3
|
+
//#region src/core/cadence.d.ts
|
|
4
|
+
type Weekday = "mon" | "tue" | "wed" | "thu" | "fri" | "sat" | "sun";
|
|
5
|
+
type Cadence = {
|
|
6
|
+
readonly kind: "hourly";
|
|
7
|
+
} | {
|
|
8
|
+
readonly kind: "daily";
|
|
9
|
+
readonly at: readonly number[] | null;
|
|
10
|
+
readonly days: readonly Weekday[] | null;
|
|
11
|
+
};
|
|
12
|
+
declare function hourly(options?: never): Cadence;
|
|
13
|
+
declare function daily(options?: {
|
|
14
|
+
at?: number | readonly number[];
|
|
15
|
+
days?: readonly string[];
|
|
16
|
+
}): Cadence;
|
|
17
|
+
declare function weekly(options: {
|
|
18
|
+
on: string;
|
|
19
|
+
at?: number | readonly number[];
|
|
20
|
+
}): Cadence;
|
|
21
|
+
//#endregion
|
|
22
|
+
//#region src/core/schedule.d.ts
|
|
23
|
+
type OverlapPolicy = "skip" | "allow" | "buffer-one";
|
|
3
24
|
interface ScheduleDefinition<TWorkflow extends AnyWorkflowDefinition$1 = AnyWorkflowDefinition$1> {
|
|
4
25
|
readonly id: string;
|
|
5
26
|
readonly workflow: TWorkflow;
|
|
6
|
-
readonly
|
|
7
|
-
readonly timeZone
|
|
27
|
+
readonly cadence: Cadence;
|
|
28
|
+
readonly timeZone: string;
|
|
29
|
+
readonly overlapPolicy?: OverlapPolicy;
|
|
30
|
+
readonly enabled?: boolean;
|
|
8
31
|
readonly input: WorkflowInput$1<NoInfer<TWorkflow>>;
|
|
9
32
|
}
|
|
10
|
-
|
|
33
|
+
interface ResolvedSchedule<TWorkflow extends AnyWorkflowDefinition$1 = AnyWorkflowDefinition$1> extends ScheduleDefinition<TWorkflow> {
|
|
34
|
+
readonly type: "schedule";
|
|
35
|
+
readonly overlapPolicy: OverlapPolicy;
|
|
36
|
+
readonly enabled: boolean;
|
|
37
|
+
}
|
|
38
|
+
declare function defineSchedule<TWorkflow extends AnyWorkflowDefinition$1>(schedule: ScheduleDefinition<TWorkflow>): ResolvedSchedule<TWorkflow>;
|
|
39
|
+
//#endregion
|
|
40
|
+
//#region src/core/trigger.d.ts
|
|
41
|
+
type TriggerDefinition = ScheduleDefinition;
|
|
42
|
+
type ResolvedTrigger = ResolvedSchedule;
|
|
11
43
|
//#endregion
|
|
12
|
-
//#region src/
|
|
44
|
+
//#region src/core/workflow.d.ts
|
|
13
45
|
interface WorkflowsDefinition<TWorkflow extends AnyWorkflowDefinition$1 = AnyWorkflowDefinition$1> {
|
|
14
46
|
readonly workflows: readonly TWorkflow[];
|
|
15
|
-
readonly
|
|
47
|
+
readonly triggers: readonly ResolvedTrigger[];
|
|
16
48
|
}
|
|
17
|
-
declare function registerWorkflows<const TWorkflows extends readonly AnyWorkflowDefinition$1[]>(
|
|
49
|
+
declare function registerWorkflows<const TWorkflows extends readonly AnyWorkflowDefinition$1[]>(definition: {
|
|
18
50
|
workflows: TWorkflows;
|
|
19
|
-
|
|
51
|
+
triggers?: readonly TriggerDefinition[];
|
|
20
52
|
}): WorkflowsDefinition<TWorkflows[number]>;
|
|
21
53
|
//#endregion
|
|
22
|
-
//#region src/graph.d.ts
|
|
54
|
+
//#region src/manifests/graph.d.ts
|
|
55
|
+
type WorkflowGraphNodeDetails = {
|
|
56
|
+
kind: "step";
|
|
57
|
+
stepId: string;
|
|
58
|
+
} | {
|
|
59
|
+
kind: "approve";
|
|
60
|
+
config: {
|
|
61
|
+
title: string;
|
|
62
|
+
description?: string;
|
|
63
|
+
};
|
|
64
|
+
} | {
|
|
65
|
+
kind: "wait-for-event";
|
|
66
|
+
config: {
|
|
67
|
+
event: string;
|
|
68
|
+
deadline?: number;
|
|
69
|
+
};
|
|
70
|
+
} | {
|
|
71
|
+
kind: "sleep";
|
|
72
|
+
config: {
|
|
73
|
+
ms: number;
|
|
74
|
+
};
|
|
75
|
+
} | {
|
|
76
|
+
kind: "sleep-until";
|
|
77
|
+
config: {
|
|
78
|
+
timestamp: number;
|
|
79
|
+
};
|
|
80
|
+
} | {
|
|
81
|
+
kind: "unknown";
|
|
82
|
+
};
|
|
83
|
+
type WorkflowGraphNode = {
|
|
84
|
+
id: string;
|
|
85
|
+
label: string;
|
|
86
|
+
} & WorkflowGraphNodeDetails;
|
|
23
87
|
interface WorkflowGraph {
|
|
24
88
|
source: "inferred";
|
|
25
89
|
scope: "handler";
|
|
26
90
|
complete: boolean;
|
|
27
|
-
nodes:
|
|
28
|
-
id: string;
|
|
29
|
-
kind: "step" | "unknown";
|
|
30
|
-
label: string;
|
|
31
|
-
stepId?: string;
|
|
32
|
-
}[];
|
|
91
|
+
nodes: WorkflowGraphNode[];
|
|
33
92
|
edges: {
|
|
34
93
|
source: string;
|
|
35
94
|
target: string;
|
|
@@ -38,12 +97,12 @@ interface WorkflowGraph {
|
|
|
38
97
|
diagnostics: string[];
|
|
39
98
|
}
|
|
40
99
|
//#endregion
|
|
41
|
-
//#region src/json.d.ts
|
|
100
|
+
//#region src/manifests/json.d.ts
|
|
42
101
|
type JsonValue = null | boolean | number | string | JsonValue[] | {
|
|
43
102
|
[key: string]: JsonValue;
|
|
44
103
|
};
|
|
45
104
|
//#endregion
|
|
46
|
-
//#region src/
|
|
105
|
+
//#region src/manifests/generate.d.ts
|
|
47
106
|
interface WorkflowManifest {
|
|
48
107
|
version: 1;
|
|
49
108
|
workflow: {
|
|
@@ -54,14 +113,129 @@ interface WorkflowManifest {
|
|
|
54
113
|
outputSchema?: JsonValue;
|
|
55
114
|
stateSchema?: JsonValue;
|
|
56
115
|
};
|
|
57
|
-
|
|
116
|
+
triggers: {
|
|
117
|
+
type: "schedule";
|
|
58
118
|
id: string;
|
|
59
|
-
|
|
119
|
+
cadence: Cadence;
|
|
60
120
|
timeZone: string;
|
|
121
|
+
enabled: boolean;
|
|
122
|
+
overlapPolicy: OverlapPolicy;
|
|
61
123
|
input: JsonValue;
|
|
62
124
|
}[];
|
|
63
125
|
graph: WorkflowGraph;
|
|
64
126
|
}
|
|
65
127
|
declare function generateManifests(definition: WorkflowsDefinition): Promise<WorkflowManifest[]>;
|
|
66
128
|
//#endregion
|
|
67
|
-
|
|
129
|
+
//#region src/stacks/tanstack/handlers.d.ts
|
|
130
|
+
/** The shape `registerWorkflows()` returns; only the list is needed to dispatch. */
|
|
131
|
+
interface WorkflowCollection {
|
|
132
|
+
readonly workflows: readonly AnyWorkflowDefinition$1[];
|
|
133
|
+
}
|
|
134
|
+
interface TanStackWorkflowHandlerOptions {
|
|
135
|
+
/** @default a process-local `inMemoryRunStore()`, lost on restart */
|
|
136
|
+
runStore?: RunStore;
|
|
137
|
+
/**
|
|
138
|
+
* Route parameter carrying the workflow ID.
|
|
139
|
+
* @default "workflowId"
|
|
140
|
+
*/
|
|
141
|
+
workflowIdParam?: string;
|
|
142
|
+
}
|
|
143
|
+
interface TanStackRouteCtx {
|
|
144
|
+
request: Request;
|
|
145
|
+
params?: Record<string, string | undefined>;
|
|
146
|
+
}
|
|
147
|
+
type TanStackWorkflowHandler = (ctx: TanStackRouteCtx) => Promise<Response>;
|
|
148
|
+
/** Build a TanStack Start `POST` handler serving every workflow in the collection. */
|
|
149
|
+
declare function createTanStackWorkflowHandler(collection: WorkflowCollection, options?: TanStackWorkflowHandlerOptions): TanStackWorkflowHandler;
|
|
150
|
+
//#endregion
|
|
151
|
+
//#region src/stacks/tanstack/steps.d.ts
|
|
152
|
+
interface StepsHandlerOptions {
|
|
153
|
+
/** Route parameter carrying the workflow ID. @default "workflowId" */
|
|
154
|
+
workflowIdParam?: string;
|
|
155
|
+
}
|
|
156
|
+
interface RouteCtx {
|
|
157
|
+
request: Request;
|
|
158
|
+
params?: Record<string, string | undefined>;
|
|
159
|
+
}
|
|
160
|
+
type StepsHandler = (ctx: RouteCtx) => Promise<Response>;
|
|
161
|
+
/** Report what a run is waiting on, running nothing. Pins ctx.now/ctx.uuid into
|
|
162
|
+
* `memo` so a later executeSteps replays the same values. */
|
|
163
|
+
declare function createNextStepsHandler(collection: WorkflowCollection, options?: StepsHandlerOptions): StepsHandler;
|
|
164
|
+
/** Run the requested steps; omitting `steps` runs whatever `nextSteps` would
|
|
165
|
+
* report, advancing the run one wave per call. */
|
|
166
|
+
declare function createExecuteStepsHandler(collection: WorkflowCollection, options?: StepsHandlerOptions): StepsHandler;
|
|
167
|
+
//#endregion
|
|
168
|
+
//#region src/stacks/tanstack/run.d.ts
|
|
169
|
+
declare function createRunHandler(collection: WorkflowCollection, options?: StepsHandlerOptions): StepsHandler;
|
|
170
|
+
//#endregion
|
|
171
|
+
//#region src/stacks/tanstack/sse.d.ts
|
|
172
|
+
/**
|
|
173
|
+
* Encode a workflow event stream as `text/event-stream`. Each event keeps its
|
|
174
|
+
* engine `type` as the SSE event name and its whole JSON as the data line.
|
|
175
|
+
*/
|
|
176
|
+
declare function toServerSentEventsResponse(events: AsyncIterable<WorkflowEvent>): Response;
|
|
177
|
+
//#endregion
|
|
178
|
+
//#region src/runtime/types.d.ts
|
|
179
|
+
/** Durable operations a replay can answer from the memo. */
|
|
180
|
+
type StepKind = "step" | "sleep" | "waitForEvent" | "approve" | "now" | "uuid";
|
|
181
|
+
/**
|
|
182
|
+
* One settled durable operation. The memo is the whole run state: the caller
|
|
183
|
+
* carries it between calls, so no run store is involved.
|
|
184
|
+
*/
|
|
185
|
+
interface MemoEntry {
|
|
186
|
+
/** Call order within the pass that recorded it. Reporting only: racing
|
|
187
|
+
* branches can order differently on a later pass, so it is not the key. */
|
|
188
|
+
seq: number;
|
|
189
|
+
stepId: string;
|
|
190
|
+
/** Which call of this `stepId` in the run, from 0. */
|
|
191
|
+
occurrence: number;
|
|
192
|
+
/** Key of the step whose body recorded this, if any; a memoized parent hides it. */
|
|
193
|
+
parent?: string;
|
|
194
|
+
kind: StepKind;
|
|
195
|
+
status: "completed" | "failed";
|
|
196
|
+
result?: unknown;
|
|
197
|
+
error?: string;
|
|
198
|
+
}
|
|
199
|
+
/** A durable operation the replay reached but could not answer. */
|
|
200
|
+
interface StepIntent {
|
|
201
|
+
seq: number;
|
|
202
|
+
stepId: string;
|
|
203
|
+
occurrence: number;
|
|
204
|
+
kind: StepKind;
|
|
205
|
+
/** Kind-specific detail: sleep `ms`, `waitForEvent` name, approval title. */
|
|
206
|
+
config?: Record<string, unknown>;
|
|
207
|
+
}
|
|
208
|
+
interface StepResult {
|
|
209
|
+
seq: number;
|
|
210
|
+
stepId: string;
|
|
211
|
+
occurrence: number;
|
|
212
|
+
kind: StepKind;
|
|
213
|
+
status: "completed" | "failed";
|
|
214
|
+
result?: unknown;
|
|
215
|
+
error?: string;
|
|
216
|
+
}
|
|
217
|
+
type ReplayStatus = "completed" | "failed" | "pending";
|
|
218
|
+
interface ReplayOutcome {
|
|
219
|
+
status: ReplayStatus;
|
|
220
|
+
/** The memo the next call should send back, including entries this pass settled. */
|
|
221
|
+
memo: MemoEntry[];
|
|
222
|
+
/** Operations that still need an answer; empty unless `status` is `pending`. */
|
|
223
|
+
steps: StepIntent[];
|
|
224
|
+
/** Operations this pass executed, in execution order. */
|
|
225
|
+
results: StepResult[];
|
|
226
|
+
/** `ctx.emit` payloads; diagnostic only, never part of replay. */
|
|
227
|
+
emitted: {
|
|
228
|
+
name: string;
|
|
229
|
+
value: Record<string, unknown>;
|
|
230
|
+
}[];
|
|
231
|
+
output?: unknown;
|
|
232
|
+
error?: string;
|
|
233
|
+
}
|
|
234
|
+
/** Identifies one durable operation for `executeSteps`. */
|
|
235
|
+
interface StepSelector {
|
|
236
|
+
stepId: string;
|
|
237
|
+
/** Defaults to 0; needed only when a run calls the same `stepId` more than once. */
|
|
238
|
+
occurrence?: number;
|
|
239
|
+
}
|
|
240
|
+
//#endregion
|
|
241
|
+
export { type AnyWorkflowDefinition, type Cadence, type Ctx, type MemoEntry, type OverlapPolicy, type ReplayOutcome, type ResolvedSchedule, type ResolvedTrigger, type ScheduleDefinition, type StepContext, type StepIntent, type StepKind, type StepOptions, type StepResult, type StepSelector, type StepsHandler, type StepsHandlerOptions, type TanStackWorkflowHandler, type TanStackWorkflowHandlerOptions, type TriggerDefinition, type Weekday, type WorkflowCollection, type WorkflowDefinition, type WorkflowGraph, type WorkflowGraphNode, type WorkflowGraphNodeDetails, type WorkflowInput, type WorkflowManifest, type WorkflowOutput, type WorkflowState, type WorkflowsDefinition, createExecuteStepsHandler, createMiddleware, createNextStepsHandler, createRunHandler, createTanStackWorkflowHandler, createWorkflow, daily, defineSchedule, generateManifests, hourly, registerWorkflows, toServerSentEventsResponse, weekly };
|