@usearazzo/runner 1.0.1-alpha.10 → 1.0.1-alpha.12

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/types/runner.d.ts CHANGED
@@ -167,10 +167,79 @@ export declare class ArazzoDocumentRegistryProvider extends DocumentRegistryProv
167
167
  */
168
168
  export declare type ArazzoDocumentRegistryProviderOptions = DocumentRegistryProviderOptions;
169
169
 
170
+ /**
171
+ * Runs the workflows of one Arazzo document.
172
+ *
173
+ * A thin facade over the building blocks: it wires a {@link DocumentRegistry},
174
+ * an {@link OpenAPIOperationExecutor}, a {@link StepExecutor} and a
175
+ * {@link WorkflowExecutor} with their defaults, so running a workflow takes a
176
+ * `load` and an `execute`. The building blocks stay public for callers that
177
+ * need to compose them differently.
178
+ * @public
179
+ */
180
+ export declare class ArazzoRunner {
181
+ #private;
182
+ readonly document: ArazzoDocument;
183
+ readonly registry: DocumentRegistry;
184
+ /**
185
+ * Loads the entry Arazzo document at `uri` (a file system path or URL) and
186
+ * returns a runner bound to it.
187
+ *
188
+ * @throws UnmatchedProviderError - When no provider can load the document
189
+ * @throws InvalidEntryDocumentError - When the document is not an Arazzo
190
+ * document, or the given registry already backs another entry document
191
+ */
192
+ static load(uri: string, options?: ArazzoRunnerLoadOptions): Promise<ArazzoRunner>;
193
+ /**
194
+ * Binds a runner to an entry document the caller already acquired.
195
+ *
196
+ * @throws InvalidEntryDocumentError - When `document` is not the entry document of `registry`
197
+ */
198
+ constructor(options: ArazzoRunnerOptions);
199
+ /**
200
+ * Runs the named workflow to completion, returning its outcome; see
201
+ * {@link WorkflowExecutor.execute}.
202
+ */
203
+ execute(workflowId: WorkflowId, options?: WorkflowExecuteOptions): Promise<WorkflowExecutionResult>;
204
+ }
205
+
170
206
  /** @public */
171
207
  export declare class ArazzoRunnerError extends ApiDOMStructuredError {
172
208
  }
173
209
 
210
+ /**
211
+ * Options for {@link ArazzoRunner.load}.
212
+ *
213
+ * Every option is a seam of a building block the runner wires: `registry` is
214
+ * the {@link DocumentRegistry} the documents load into (a fresh one with the
215
+ * default providers when omitted), `httpClient` and `requestInterceptor` go to
216
+ * the {@link OpenAPIOperationExecutor}, and the rest go to the
217
+ * {@link WorkflowExecutor}.
218
+ * @public
219
+ */
220
+ export declare interface ArazzoRunnerLoadOptions extends Pick<OpenAPIOperationExecutorOptions, 'httpClient' | 'requestInterceptor'>, Pick<WorkflowExecutorOptions, 'maxSteps' | 'maxWorkflowDepth' | 'sleep' | 'now'> {
221
+ /**
222
+ * The registry to load the documents into. A registry backs one entry
223
+ * document: loading a different one into it throws.
224
+ */
225
+ readonly registry?: DocumentRegistry;
226
+ }
227
+
228
+ /**
229
+ * Options for the ArazzoRunner constructor.
230
+ * @public
231
+ */
232
+ export declare interface ArazzoRunnerOptions extends Omit<ArazzoRunnerLoadOptions, 'registry'> {
233
+ /**
234
+ * The entry Arazzo document holding the workflows to run.
235
+ */
236
+ readonly document: ArazzoDocument;
237
+ /**
238
+ * The document registry whose entry document is `document`.
239
+ */
240
+ readonly registry: DocumentRegistry;
241
+ }
242
+
174
243
  /**
175
244
  * Index mapping a source description name to its element and canonical URI in
176
245
  * an Arazzo document.
@@ -1192,15 +1261,23 @@ export declare interface OpenAPIOperationRequestInfo {
1192
1261
 
1193
1262
  /**
1194
1263
  * Response from an OpenAPI operation execution.
1264
+ *
1265
+ * `body` is the payload parsed by its content type, what `$response.body`
1266
+ * reads. The body as received is read through `text()`, `blob()` and
1267
+ * `bytes()`, named after the WHATWG `Response` methods but synchronous, and
1268
+ * empty when the response carried no body (e.g. `204`, `304`). `bytes()` and
1269
+ * `blob()` always return the bytes received. A body that is valid UTF-8 is held
1270
+ * as its decoded string, which a plain-text or XML `body` shares rather than
1271
+ * duplicates, and is encoded back on read; any other body is held as bytes.
1195
1272
  * @public
1196
1273
  */
1197
1274
  export declare class OpenAPIOperationResponse {
1275
+ #private;
1198
1276
  readonly ok: boolean;
1199
1277
  readonly url: string;
1200
1278
  readonly status: number;
1201
1279
  readonly statusText: string;
1202
1280
  readonly headers: Record<string, string>;
1203
- readonly text: string;
1204
1281
  readonly body: unknown;
1205
1282
  readonly request: OpenAPIOperationRequestInfo | undefined;
1206
1283
  constructor(raw: {
@@ -1209,10 +1286,24 @@ export declare class OpenAPIOperationResponse {
1209
1286
  status: number;
1210
1287
  statusText: string;
1211
1288
  headers: Record<string, string>;
1212
- text: string;
1213
1289
  body: unknown;
1290
+ content: string | Uint8Array;
1214
1291
  request?: OpenAPIOperationRequestInfo;
1215
1292
  });
1293
+ /**
1294
+ * The body as text, like `Response.text()`; `''` when there is none.
1295
+ */
1296
+ text(): string;
1297
+ /**
1298
+ * The body as a `Blob` typed by the response's `Content-Type`, like
1299
+ * `Response.blob()`.
1300
+ */
1301
+ blob(): Blob;
1302
+ /**
1303
+ * The body as bytes, like `Response.bytes()`; a fresh copy on every call, so
1304
+ * the response stays immutable.
1305
+ */
1306
+ bytes(): Uint8Array;
1216
1307
  }
1217
1308
 
1218
1309
  /**
@@ -1226,10 +1317,15 @@ export declare class OpenAPIOperationResponse {
1226
1317
  * Headers are taken from the `Response` directly rather than from the
1227
1318
  * deserializer, which splits every value containing `", "` into an array:
1228
1319
  * values stay strings as sent, with repeated fields (`Set-Cookie` included)
1229
- * combined by `Headers.get`.
1320
+ * combined by `Headers.get`. The body is read once, as bytes, and handed to the
1321
+ * deserializer from memory. A body that decodes as UTF-8 without loss is kept
1322
+ * as that one string, the same one the deserializer parses, so a plain-text or
1323
+ * XML `body` shares it; any other body (binary, another charset, a leading
1324
+ * byte-order mark) is kept as the bytes, so they are never re-encoded lossily.
1230
1325
  * @public
1231
1326
  */
1232
1327
  export declare class OpenAPIOperationResponseNormalizer {
1328
+ #private;
1233
1329
  /**
1234
1330
  * Deserializes the response body by content type and maps the result into the
1235
1331
  * runner's response model. `request` is the request the operation was