@lovable.dev/workflows-sdk 0.0.0-dev.55 → 0.0.0-dev.57

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/index.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  import { AccumulateExtensions, AnyMiddleware, AnyWorkflowDefinition, AnyWorkflowDefinition as AnyWorkflowDefinition$1, ApprovalResult, ApproveOptions as ApproveOptions$1, CreateWorkflowConfig, Ctx as Ctx$1, InferSchema, RunStore, SchemaInput, StepContext, StepContext as StepContext$1, StepOptions, StepOptions as StepOptions$1, WaitForEventOptions as WaitForEventOptions$1, WorkflowBuilder, WorkflowDefinition, WorkflowDefinition as WorkflowDefinition$1, WorkflowEvent, WorkflowInput, WorkflowInput as WorkflowInput$1, WorkflowMetadata, WorkflowOutput, WorkflowState, createMiddleware } from "@tanstack/workflow-core";
2
+ import { StandardSchemaV1 } from "@standard-schema/spec";
2
3
  //#region src/core/step-metadata.d.ts
3
4
  interface WorkflowStepGroup {
4
5
  id: string;
@@ -54,8 +55,13 @@ type LlmStep = (request: LlmRequest, options: LlmStepOptions) => Promise<string>
54
55
  //#endregion
55
56
  //#region src/core/cadence.d.ts
56
57
  type Weekday = "mon" | "tue" | "wed" | "thu" | "fri" | "sat" | "sun";
58
+ /** The intervals every({ minutes }) accepts; each divides the hour. */
59
+ type MinuteInterval = 5 | 10 | 15 | 20 | 30;
57
60
  type Cadence = {
58
61
  readonly kind: "hourly";
62
+ } | {
63
+ readonly kind: "minutes";
64
+ readonly interval: MinuteInterval;
59
65
  } | {
60
66
  readonly kind: "daily";
61
67
  readonly at: readonly number[];
@@ -65,6 +71,9 @@ type Cadence = {
65
71
  readonly at: readonly number[];
66
72
  };
67
73
  declare function hourly(options?: never): Cadence;
74
+ declare function every(options: {
75
+ minutes: MinuteInterval;
76
+ }): Cadence;
68
77
  declare function daily(options: {
69
78
  at: number[];
70
79
  }): Cadence;
@@ -308,6 +317,10 @@ type WorkflowManifestCadenceV1Json = {
308
317
  * @generated from field: lovable.appworkflows.v1.WorkflowManifestWeeklyCadenceV1 weekly = 3;
309
318
  */
310
319
  weekly?: WorkflowManifestWeeklyCadenceV1Json;
320
+ /**
321
+ * @generated from field: lovable.appworkflows.v1.WorkflowManifestMinutesCadenceV1 minutes = 4;
322
+ */
323
+ minutes?: WorkflowManifestMinutesCadenceV1Json;
311
324
  };
312
325
  /**
313
326
  * Runs once per hour at a platform-selected offset within the hour.
@@ -315,6 +328,20 @@ type WorkflowManifestCadenceV1Json = {
315
328
  * @generated from message lovable.appworkflows.v1.WorkflowManifestHourlyCadenceV1
316
329
  */
317
330
  type WorkflowManifestHourlyCadenceV1Json = {};
331
+ /**
332
+ * Runs every interval minutes on UTC minutes, whatever the schedule's time
333
+ * zone, at a platform-selected offset within each interval.
334
+ *
335
+ * @generated from message lovable.appworkflows.v1.WorkflowManifestMinutesCadenceV1
336
+ */
337
+ type WorkflowManifestMinutesCadenceV1Json = {
338
+ /**
339
+ * Is 5, 10, 15, 20, or 30.
340
+ *
341
+ * @generated from field: uint32 interval = 1;
342
+ */
343
+ interval?: number;
344
+ };
318
345
  /**
319
346
  * Runs daily during the selected hours in the schedule's time zone.
320
347
  *
@@ -1016,4 +1043,299 @@ declare function createStepsHandler(collection: WorkflowCollection, options?: St
1016
1043
  */
1017
1044
  declare function toServerSentEventsResponse(events: AsyncIterable<WorkflowEvent>): Response;
1018
1045
  //#endregion
1019
- export { type AnyWorkflowDefinition, type ApproveOptions, type Cadence, type ConnectorStep, type ConnectorStepOptions, type Ctx, type LlmRequest, type LlmStep, type LlmStepOptions, type MemoEntry, type NextStep, type OverlapPolicy, type ReplayOutcome, type ResolvedSchedule, type ResolvedTrigger, type ScheduleDefinition, type StepContext, type StepIntent, type StepKind, type StepOptions, type StepReference, type StepResult, type StepsDisposition, type StepsHandler, type StepsHandlerOptions, type StepsRequest, type StepsResponse, type TanStackWorkflowHandler, type TanStackWorkflowHandlerOptions, type TriggerDefinition, type WaitForEventOptions, type Weekday, type WorkflowBranchMetadata, type WorkflowCollection, type WorkflowDefinition, type WorkflowInput, type WorkflowManifest, type WorkflowOperationMetadata, type WorkflowOutput, type WorkflowState, type WorkflowStepGroup, type WorkflowStepMetadata, type WorkflowsDefinition, createMiddleware, createStepsHandler, createTanStackWorkflowHandler, createWorkflow, daily, defineSchedule, generateManifests, hourly, registerWorkflows, toServerSentEventsResponse, weekly };
1046
+ //#region src/client/generated/gateway.d.ts
1047
+ interface components {
1048
+ schemas: {
1049
+ DeliverEventRequest: {
1050
+ /** @description Makes the delivery safe to retry. A delivery that repeats the event_id is accepted and records nothing new. The same event_id with another name answers 409. */
1051
+ event_id: string;
1052
+ /** @description The event name that the run's ctx.waitForEvent call waits on. */
1053
+ name: string;
1054
+ /** @description The value that the ctx.waitForEvent call resolves to, any JSON value. Omit it for an event that carries no data. */
1055
+ payload?: unknown;
1056
+ };
1057
+ DeliverEventResponse: {
1058
+ /** @description Is false when an earlier delivery with the same event_id already recorded the event. */
1059
+ recorded: boolean;
1060
+ };
1061
+ Error: {
1062
+ /** @description Explanation of this occurrence, or null. */
1063
+ detail: string | null;
1064
+ /** @description The invalid request values, or null. */
1065
+ errors: components["schemas"]["ErrorDetail"][] | null;
1066
+ /** @description Extra data for the error type, or null. */
1067
+ props: {
1068
+ [key: string]: unknown;
1069
+ } | null;
1070
+ /** @description Identifier of this request. Quote it when you report a failure. */
1071
+ request_id: string;
1072
+ /**
1073
+ * Format: int64
1074
+ * @description HTTP status code.
1075
+ */
1076
+ status: number;
1077
+ /** @description Short, human-readable summary. */
1078
+ title: string;
1079
+ /** @description Machine-readable error type in snake_case. */
1080
+ type: string;
1081
+ };
1082
+ ErrorDetail: {
1083
+ /** @description Where the value is, such as body.input, or null. */
1084
+ location: string | null;
1085
+ /** @description What is wrong with the value. */
1086
+ message: string;
1087
+ };
1088
+ Run: {
1089
+ /**
1090
+ * Format: date-time
1091
+ * @description When the run reached a final status, or null while it is open.
1092
+ */
1093
+ closed_at: string | null;
1094
+ /**
1095
+ * Format: date-time
1096
+ * @description When the run was created.
1097
+ */
1098
+ created_at: string;
1099
+ /** @description Why the run failed or was cancelled, or null. */
1100
+ error: string | null;
1101
+ /** @description The run's input, any JSON value, or null when the run has no input. */
1102
+ input: unknown;
1103
+ /** @description The value that the workflow returned, any JSON value, or null until the run is completed. */
1104
+ output: unknown;
1105
+ /** @description Identifier of the run. */
1106
+ run_id: string;
1107
+ /**
1108
+ * @description The run's status. completed, failed, cancelled and skipped are final.
1109
+ * @enum {string}
1110
+ */
1111
+ status: "queued" | "running" | "waiting" | "completed" | "failed" | "cancelled" | "skipped" | "unknown";
1112
+ /**
1113
+ * @description What started the run. A run that the app's code starts is api.
1114
+ * @enum {string}
1115
+ */
1116
+ trigger: "manual" | "schedule" | "event" | "webhook" | "api" | "unknown";
1117
+ /**
1118
+ * Format: date-time
1119
+ * @description When the run last changed.
1120
+ */
1121
+ updated_at: string;
1122
+ /** @description The workflow that the run executes. */
1123
+ workflow_id: string;
1124
+ };
1125
+ RunSummary: {
1126
+ /**
1127
+ * Format: date-time
1128
+ * @description When the run was created.
1129
+ */
1130
+ created_at: string;
1131
+ /** @description Identifier of the run. */
1132
+ run_id: string;
1133
+ /**
1134
+ * @description The run's status when the response was written.
1135
+ * @enum {string}
1136
+ */
1137
+ status: "queued" | "running" | "waiting" | "completed" | "failed" | "cancelled" | "skipped" | "unknown";
1138
+ /**
1139
+ * @description What started the run. A run that the app's code starts is api.
1140
+ * @enum {string}
1141
+ */
1142
+ trigger: "manual" | "schedule" | "event" | "webhook" | "api" | "unknown";
1143
+ /** @description The workflow that the run executes. */
1144
+ workflow_id: string;
1145
+ };
1146
+ StartRunRequest: {
1147
+ /** @description The run's input, any JSON value. Omit it for a workflow that takes no input. */
1148
+ input?: unknown;
1149
+ };
1150
+ };
1151
+ responses: never;
1152
+ parameters: never;
1153
+ requestBodies: never;
1154
+ headers: never;
1155
+ pathItems: never;
1156
+ }
1157
+ //#endregion
1158
+ //#region src/client/runs.d.ts
1159
+ type WireRun = components["schemas"]["Run"];
1160
+ /** `completed`, `failed`, `cancelled` and `skipped` are final. Treat `unknown`, and any status added later, as open. */
1161
+ type RunStatus = WireRun["status"];
1162
+ type RunTrigger = WireRun["trigger"];
1163
+ interface RunSummary {
1164
+ runId: string;
1165
+ workflowId: string;
1166
+ /** The status when the gateway answered. A start that repeats an Idempotency-Key returns the run in its current state. */
1167
+ status: RunStatus;
1168
+ /** `api` for a run that app code started. */
1169
+ trigger: RunTrigger;
1170
+ createdAt: string;
1171
+ }
1172
+ interface Run extends RunSummary {
1173
+ updatedAt: string;
1174
+ /** Null while the run is open. */
1175
+ closedAt: string | null;
1176
+ /** Why the run failed or was cancelled, or null. */
1177
+ error: string | null;
1178
+ input: unknown;
1179
+ /** Set only once the run is `completed`. */
1180
+ output: unknown;
1181
+ }
1182
+ interface StartRunOptions {
1183
+ /**
1184
+ * Makes the start safe to retry: 1–64 printable ASCII characters, derived from the event that starts the run.
1185
+ * A repeat with the same key and input returns the run the key started.
1186
+ */
1187
+ idempotencyKey?: string;
1188
+ signal?: AbortSignal;
1189
+ }
1190
+ interface GetRunOptions {
1191
+ signal?: AbortSignal;
1192
+ }
1193
+ interface DeliverEventInput {
1194
+ /** Makes the delivery safe to retry. */
1195
+ eventId: string;
1196
+ /** The name that the run's `ctx.waitForEvent` call waits on. */
1197
+ name: string;
1198
+ /** What `ctx.waitForEvent` resolves to. Omit it for an event that carries no data. */
1199
+ payload?: unknown;
1200
+ }
1201
+ interface DeliverEventOptions {
1202
+ signal?: AbortSignal;
1203
+ }
1204
+ interface DeliverEventResult {
1205
+ /** False when an earlier delivery with the same `eventId` already recorded the event. */
1206
+ recorded: boolean;
1207
+ }
1208
+ type StartRunArgs<W extends AnyWorkflowDefinition$1> = undefined extends WorkflowInput$1<W> ? [input?: WorkflowInput$1<W>, options?: StartRunOptions] : [input: WorkflowInput$1<W>, options?: StartRunOptions];
1209
+ /**
1210
+ * Starts a run of the published version of one of the app's workflows. Call it from server code only.
1211
+ *
1212
+ * Pass the workflow's definition to type the input and check it against the workflow's input schema before anything
1213
+ * is sent, or pass the workflow id. The SDK never retries and never makes up an Idempotency-Key: derive the key from
1214
+ * the event, and retry with the same key and input.
1215
+ */
1216
+ declare function startRun<W extends AnyWorkflowDefinition$1>(workflow: W, ...args: StartRunArgs<W>): Promise<RunSummary>;
1217
+ declare function startRun(workflowId: string, input?: unknown, options?: StartRunOptions): Promise<RunSummary>;
1218
+ /**
1219
+ * Reads one of the app's runs, with its input and output. Call it from server code only.
1220
+ *
1221
+ * The app's key reads every run of its project: runs it started, scheduled runs and editor test runs.
1222
+ */
1223
+ declare function getRun(runId: string, options?: GetRunOptions): Promise<Run>;
1224
+ /**
1225
+ * Resumes the run's `ctx.waitForEvent` call that waits on the event's name. Call it from server code only.
1226
+ *
1227
+ * Events are not queued: an open run that doesn't wait on the name yet throws `RunNotWaitingError`, which can be
1228
+ * retried, and a finished run throws `RunClosedError`. A retry with the same `eventId` is always safe.
1229
+ */
1230
+ declare function deliverEvent(runId: string, event: DeliverEventInput, options?: DeliverEventOptions): Promise<DeliverEventResult>;
1231
+ //#endregion
1232
+ //#region src/client/errors.d.ts
1233
+ /** One invalid request value, as the gateway reports it in `errors`. */
1234
+ interface WorkflowsErrorDetail {
1235
+ location: string | null;
1236
+ message: string;
1237
+ }
1238
+ interface WorkflowsApiErrorJSON {
1239
+ name: string;
1240
+ message: string;
1241
+ type: string;
1242
+ status?: number;
1243
+ requestId?: string;
1244
+ title?: string;
1245
+ detail?: string;
1246
+ errors?: WorkflowsErrorDetail[];
1247
+ retryable: boolean;
1248
+ retryAfterMs?: number;
1249
+ }
1250
+ interface WorkflowsApiErrorFields {
1251
+ type: string;
1252
+ retryable: boolean;
1253
+ status?: number;
1254
+ requestId?: string;
1255
+ title?: string;
1256
+ detail?: string;
1257
+ errors?: WorkflowsErrorDetail[];
1258
+ retryAfterMs?: number;
1259
+ cause?: unknown;
1260
+ }
1261
+ /**
1262
+ * A failed `startRun`, `getRun` or `deliverEvent` call.
1263
+ *
1264
+ * `status` is the gateway's HTTP status, and is undefined when the SDK refused the call before sending it or got no
1265
+ * response. `retryable` is true when repeating the same call later can succeed without a change to the code, the
1266
+ * configuration or the app; the SDK itself never retries.
1267
+ */
1268
+ declare class WorkflowsApiError extends Error {
1269
+ readonly name: string;
1270
+ readonly type: string;
1271
+ readonly status?: number;
1272
+ readonly requestId?: string;
1273
+ readonly title?: string;
1274
+ readonly detail?: string;
1275
+ readonly errors?: WorkflowsErrorDetail[];
1276
+ readonly retryable: boolean;
1277
+ readonly retryAfterMs?: number;
1278
+ constructor(message: string, fields: WorkflowsApiErrorFields);
1279
+ toJSON(): WorkflowsApiErrorJSON;
1280
+ }
1281
+ type ConfigurationErrorReason = "server_only" | "missing_api_key" | "invalid_url";
1282
+ declare class WorkflowsConfigurationError extends WorkflowsApiError {
1283
+ readonly name = "WorkflowsConfigurationError";
1284
+ readonly reason: ConfigurationErrorReason;
1285
+ constructor(reason: ConfigurationErrorReason, message: string);
1286
+ }
1287
+ declare class WorkflowsRequestInvalidError extends WorkflowsApiError {
1288
+ readonly name: string;
1289
+ }
1290
+ /** The input fails the workflow's input schema. The SDK sent no request, so the Idempotency-Key is still unused. */
1291
+ declare class RunInputInvalidError extends WorkflowsRequestInvalidError {
1292
+ readonly name = "RunInputInvalidError";
1293
+ readonly issues: readonly StandardSchemaV1.Issue[];
1294
+ constructor(message: string, fields: WorkflowsApiErrorFields & {
1295
+ issues: readonly StandardSchemaV1.Issue[];
1296
+ });
1297
+ }
1298
+ declare class WorkflowsNetworkError extends WorkflowsApiError {
1299
+ readonly name = "WorkflowsNetworkError";
1300
+ }
1301
+ declare class WorkflowsAuthenticationError extends WorkflowsApiError {
1302
+ readonly name = "WorkflowsAuthenticationError";
1303
+ }
1304
+ declare class WorkflowsKeyLookupError extends WorkflowsApiError {
1305
+ readonly name = "WorkflowsKeyLookupError";
1306
+ }
1307
+ declare class WorkflowsDevelopmentKeyError extends WorkflowsApiError {
1308
+ readonly name = "WorkflowsDevelopmentKeyError";
1309
+ }
1310
+ declare class WorkflowsDisabledError extends WorkflowsApiError {
1311
+ readonly name = "WorkflowsDisabledError";
1312
+ }
1313
+ declare class RunNotFoundError extends WorkflowsApiError {
1314
+ readonly name = "RunNotFoundError";
1315
+ }
1316
+ declare class WorkflowNotPublishedError extends WorkflowsApiError {
1317
+ readonly name = "WorkflowNotPublishedError";
1318
+ }
1319
+ declare class IdempotencyKeyReusedError extends WorkflowsApiError {
1320
+ readonly name = "IdempotencyKeyReusedError";
1321
+ }
1322
+ declare class RunClosedError extends WorkflowsApiError {
1323
+ readonly name = "RunClosedError";
1324
+ }
1325
+ declare class RunNotWaitingError extends WorkflowsApiError {
1326
+ readonly name = "RunNotWaitingError";
1327
+ }
1328
+ declare class EventAlreadyDeliveredError extends WorkflowsApiError {
1329
+ readonly name = "EventAlreadyDeliveredError";
1330
+ }
1331
+ declare class WorkflowsPayloadTooLargeError extends WorkflowsApiError {
1332
+ readonly name = "WorkflowsPayloadTooLargeError";
1333
+ }
1334
+ declare class WorkflowsRateLimitedError extends WorkflowsApiError {
1335
+ readonly name = "WorkflowsRateLimitedError";
1336
+ }
1337
+ declare class WorkflowsUnavailableError extends WorkflowsApiError {
1338
+ readonly name = "WorkflowsUnavailableError";
1339
+ }
1340
+ //#endregion
1341
+ export { type AnyWorkflowDefinition, type ApproveOptions, type Cadence, type ConfigurationErrorReason, type ConnectorStep, type ConnectorStepOptions, type Ctx, type DeliverEventInput, type DeliverEventOptions, type DeliverEventResult, EventAlreadyDeliveredError, type GetRunOptions, IdempotencyKeyReusedError, type LlmRequest, type LlmStep, type LlmStepOptions, type MemoEntry, type MinuteInterval, type NextStep, type OverlapPolicy, type ReplayOutcome, type ResolvedSchedule, type ResolvedTrigger, type Run, RunClosedError, RunInputInvalidError, RunNotFoundError, RunNotWaitingError, type RunStatus, type RunSummary, type RunTrigger, type ScheduleDefinition, type StartRunOptions, type StepContext, type StepIntent, type StepKind, type StepOptions, type StepReference, type StepResult, type StepsDisposition, type StepsHandler, type StepsHandlerOptions, type StepsRequest, type StepsResponse, type TanStackWorkflowHandler, type TanStackWorkflowHandlerOptions, type TriggerDefinition, type WaitForEventOptions, type Weekday, type WorkflowBranchMetadata, type WorkflowCollection, type WorkflowDefinition, type WorkflowInput, type WorkflowManifest, WorkflowNotPublishedError, type WorkflowOperationMetadata, type WorkflowOutput, type WorkflowState, type WorkflowStepGroup, type WorkflowStepMetadata, WorkflowsApiError, type WorkflowsApiErrorJSON, WorkflowsAuthenticationError, WorkflowsConfigurationError, type WorkflowsDefinition, WorkflowsDevelopmentKeyError, WorkflowsDisabledError, type WorkflowsErrorDetail, WorkflowsKeyLookupError, WorkflowsNetworkError, WorkflowsPayloadTooLargeError, WorkflowsRateLimitedError, WorkflowsRequestInvalidError, WorkflowsUnavailableError, createMiddleware, createStepsHandler, createTanStackWorkflowHandler, createWorkflow, daily, defineSchedule, deliverEvent, every, generateManifests, getRun, hourly, registerWorkflows, startRun, toServerSentEventsResponse, weekly };