@ancplua/qyl-api-schema 8.0.0 → 10.0.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.
package/api/workflow.tsp DELETED
@@ -1,307 +0,0 @@
1
- import "@typespec/events";
2
- import "@typespec/http";
3
- import "@typespec/sse";
4
-
5
- import "../common/errors.tsp";
6
- import "../models/workflow.tsp";
7
- import "./routes.tsp";
8
-
9
- using TypeSpec.Events;
10
- using TypeSpec.Http;
11
- using TypeSpec.SSE;
12
-
13
- using Qyl.Api.Contracts.Common.Errors;
14
- using Qyl.Api.Contracts.Workflow;
15
-
16
- namespace Qyl.Api.Contracts.Workflow;
17
-
18
- @doc("Keep-alive emitted while a workflow event stream has no new event.")
19
- model WorkflowHeartbeatEvent {
20
- type: "heartbeat";
21
-
22
- @encodedName("application/json", "high_water_mark")
23
- highWaterMark: WorkflowJournalPosition;
24
-
25
- timestamp: utcDateTime;
26
- }
27
-
28
- @doc("Signals that the requested cursor predates retained workflow history.")
29
- model WorkflowCursorGapEvent {
30
- type: "cursor_gap";
31
-
32
- @encodedName("application/json", "oldest_available_sequence")
33
- oldestAvailableSequence: WorkflowJournalPosition;
34
-
35
- @encodedName("application/json", "high_water_mark")
36
- highWaterMark: WorkflowJournalPosition;
37
-
38
- timestamp: utcDateTime;
39
- }
40
-
41
- @events
42
- union WorkflowStreamEvents {
43
- event: WorkflowJournalEvent,
44
- heartbeat: WorkflowHeartbeatEvent,
45
- cursorGap: WorkflowCursorGapEvent,
46
- }
47
-
48
- @doc("Which opaque graph cursor was rejected.")
49
- enum WorkflowCursorKind {
50
- node: "node",
51
- edge: "edge",
52
- }
53
-
54
- @doc("Why an opaque graph cursor cannot be reused for this request.")
55
- enum WorkflowCursorFailureReason {
56
- invalid: "invalid",
57
- wrongRun: "wrong_run",
58
- wrongGeneration: "wrong_generation",
59
- stale: "stale",
60
- }
61
-
62
- @doc("Opaque graph cursor is malformed, belongs to another run, or targets a stale generation.")
63
- @error
64
- model WorkflowCursorError extends ProblemDetails {
65
- @statusCode _: 409;
66
- title: "Invalid Workflow Cursor";
67
-
68
- @encodedName("application/json", "cursor_kind")
69
- cursorKind: WorkflowCursorKind;
70
-
71
- reason: WorkflowCursorFailureReason;
72
-
73
- @encodedName("application/json", "current_generation")
74
- currentGeneration?: WorkflowGeneration;
75
- }
76
-
77
- @doc("Workflow run was durably deleted and can no longer accept events or publish projections.")
78
- @error
79
- model WorkflowRunDeletedError extends ProblemDetails {
80
- @statusCode _: 410;
81
- title: "Workflow Run Deleted";
82
-
83
- @encodedName("application/json", "run_id")
84
- runId: WorkflowRunId;
85
- }
86
-
87
- @doc("Workflow projection is rebuilding or temporarily unavailable after a retryable storage failure.")
88
- @error
89
- model WorkflowProjectionUnavailableError extends ProblemDetails {
90
- @statusCode _: 503;
91
- title: "Workflow Projection Unavailable";
92
-
93
- @header("Retry-After")
94
- @encodedName("application/json", "retry_after")
95
- retryAfter: int32;
96
-
97
- @encodedName("application/json", "projection_status")
98
- projectionStatus: WorkflowProjectionStatus;
99
- }
100
-
101
- @doc("Workflow projection is non-retryably corrupt or incompatible. Internal storage details are intentionally omitted.")
102
- @error
103
- model WorkflowProjectionCorruptError extends ProblemDetails {
104
- @statusCode _: 500;
105
- title: "Workflow Projection Corrupt";
106
- @encodedName("application/json", "projection_status")
107
- projectionStatus: WorkflowProjectionStatus;
108
- }
109
-
110
- @route("/api/v1/workflow-runs")
111
- @tag("Workflow runs")
112
- @useAuth(Qyl.Api.Contracts.QylApiKeyHeaderAuth)
113
- interface WorkflowRunsApi {
114
- @post
115
- create(
116
- ...Qyl.Api.Contracts.ProjectScopeHeader,
117
- @body request: WorkflowRunCreateRequest,
118
- ):
119
- | WorkflowRun
120
- | ValidationError
121
- | UnauthorizedError
122
- | ConflictError
123
- | WorkflowRunDeletedError
124
- | ServiceUnavailableError
125
- | InternalServerError;
126
-
127
- @get
128
- list(
129
- ...Qyl.Api.Contracts.ProjectScopeHeader,
130
- @query status?: WorkflowRunStatus,
131
- @query
132
- @minValue(1)
133
- @maxValue(200)
134
- limit?: int32 = 50,
135
- @doc("Opaque continuation scoped to the project and status filter. Reuse it unchanged from next_cursor; do not parse, construct, or modify it.")
136
- @query cursor?: WorkflowRunCursor,
137
- ):
138
- | WorkflowRunPage
139
- | ValidationError
140
- | UnauthorizedError
141
- | ServiceUnavailableError
142
- | InternalServerError;
143
-
144
- @get
145
- @route("/{run_id}")
146
- get(
147
- ...Qyl.Api.Contracts.ProjectScopeHeader,
148
- @path("run_id") runId: WorkflowRunId,
149
- ):
150
- | WorkflowRun
151
- | UnauthorizedError
152
- | NotFoundError
153
- | WorkflowRunDeletedError
154
- | ServiceUnavailableError
155
- | InternalServerError;
156
-
157
- @post
158
- @route("/{run_id}/events")
159
- appendEvents(
160
- ...Qyl.Api.Contracts.ProjectScopeHeader,
161
- @path("run_id") runId: WorkflowRunId,
162
- @body request: WorkflowEventBatchAppendRequest,
163
- ):
164
- | WorkflowEventBatchAppendResponse
165
- | ValidationError
166
- | UnauthorizedError
167
- | NotFoundError
168
- | WorkflowRunDeletedError
169
- | ConflictError
170
- | ServiceUnavailableError
171
- | InternalServerError;
172
-
173
- @get
174
- @route("/{run_id}/events")
175
- readEvents(
176
- ...Qyl.Api.Contracts.ProjectScopeHeader,
177
- @path("run_id") runId: WorkflowRunId,
178
- @query("after_sequence") afterSequence?: WorkflowJournalPosition,
179
- @query
180
- @minValue(1)
181
- @maxValue(1000)
182
- limit?: int32 = 250,
183
- @query("wait_ms")
184
- @minValue(0)
185
- @maxValue(30000)
186
- waitMs?: int32 = 0,
187
- ):
188
- | WorkflowEventPage
189
- | ValidationError
190
- | UnauthorizedError
191
- | NotFoundError
192
- | WorkflowRunDeletedError
193
- | ServiceUnavailableError
194
- | InternalServerError;
195
-
196
- @get
197
- @route("/{run_id}/graph")
198
- getGraph(
199
- ...Qyl.Api.Contracts.ProjectScopeHeader,
200
- @path("run_id") runId: WorkflowRunId,
201
- @doc("Opaque node continuation. Reuse it unchanged from the preceding snapshot's next_node_cursor; do not parse, construct, or modify it.")
202
- @query("node_cursor") nodeCursor?: WorkflowNodeCursor,
203
- @query("node_limit")
204
- @minValue(1)
205
- @maxValue(1000)
206
- nodeLimit?: int32 = 250,
207
- @doc("Opaque edge continuation. Reuse it unchanged from the preceding snapshot's next_edge_cursor; do not parse, construct, or modify it.")
208
- @query("edge_cursor") edgeCursor?: WorkflowEdgeCursor,
209
- @query("edge_limit")
210
- @minValue(1)
211
- @maxValue(2000)
212
- edgeLimit?: int32 = 500,
213
- ):
214
- | WorkflowGraphSnapshot
215
- | ValidationError
216
- | UnauthorizedError
217
- | NotFoundError
218
- | WorkflowRunDeletedError
219
- | WorkflowCursorError
220
- | WorkflowProjectionUnavailableError
221
- | WorkflowProjectionCorruptError;
222
-
223
- @get
224
- @route("/{run_id}/content/{content_ref}")
225
- getContent(
226
- ...Qyl.Api.Contracts.ProjectScopeHeader,
227
- @path("run_id") runId: WorkflowRunId,
228
- @path("content_ref") contentRef: WorkflowContentRef,
229
- ):
230
- | WorkflowContent
231
- | UnauthorizedError
232
- | NotFoundError
233
- | WorkflowRunDeletedError
234
- | ServiceUnavailableError
235
- | InternalServerError;
236
-
237
- @get
238
- @route("/{run_id}/stream")
239
- stream(
240
- ...Qyl.Api.Contracts.ProjectScopeHeader,
241
- @path("run_id") runId: WorkflowRunId,
242
- @header("Last-Event-ID") lastEventId?: string,
243
- ):
244
- | SSEStream<WorkflowStreamEvents>
245
- | ValidationError
246
- | UnauthorizedError
247
- | NotFoundError
248
- | WorkflowRunDeletedError
249
- | ServiceUnavailableError
250
- | InternalServerError;
251
-
252
- @post
253
- @route("/{run_id}/commands")
254
- submitControl(
255
- ...Qyl.Api.Contracts.ProjectScopeHeader,
256
- @path("run_id") runId: WorkflowRunId,
257
- @body request: WorkflowControlRequest,
258
- ):
259
- | WorkflowControlCommand
260
- | ValidationError
261
- | UnauthorizedError
262
- | NotFoundError
263
- | WorkflowRunDeletedError
264
- | ConflictError
265
- | ServiceUnavailableError
266
- | InternalServerError;
267
-
268
- @get
269
- @route("/{run_id}/commands")
270
- pollControls(
271
- ...Qyl.Api.Contracts.ProjectScopeHeader,
272
- @path("run_id") runId: WorkflowRunId,
273
- @query("after_sequence") afterSequence?: WorkflowSequence,
274
- @query
275
- @minValue(1)
276
- @maxValue(100)
277
- limit?: int32 = 20,
278
- @query("wait_ms")
279
- @minValue(0)
280
- @maxValue(30000)
281
- waitMs?: int32 = 0,
282
- ):
283
- | WorkflowControlCommandPage
284
- | ValidationError
285
- | UnauthorizedError
286
- | NotFoundError
287
- | WorkflowRunDeletedError
288
- | ServiceUnavailableError
289
- | InternalServerError;
290
-
291
- @post
292
- @route("/{run_id}/commands/{command_id}/status")
293
- updateControl(
294
- ...Qyl.Api.Contracts.ProjectScopeHeader,
295
- @path("run_id") runId: WorkflowRunId,
296
- @path("command_id") commandId: WorkflowCommandId,
297
- @body request: WorkflowControlStatusUpdateRequest,
298
- ):
299
- | WorkflowControlCommand
300
- | ValidationError
301
- | UnauthorizedError
302
- | NotFoundError
303
- | WorkflowRunDeletedError
304
- | ConflictError
305
- | ServiceUnavailableError
306
- | InternalServerError;
307
- }