@rushstack/operation-graph 0.1.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.
Files changed (49) hide show
  1. package/LICENSE +24 -0
  2. package/README.md +12 -0
  3. package/dist/operation-graph.d.ts +572 -0
  4. package/dist/tsdoc-metadata.json +11 -0
  5. package/lib/IOperationRunner.d.ts +85 -0
  6. package/lib/IOperationRunner.d.ts.map +1 -0
  7. package/lib/IOperationRunner.js +5 -0
  8. package/lib/IOperationRunner.js.map +1 -0
  9. package/lib/Operation.d.ts +155 -0
  10. package/lib/Operation.d.ts.map +1 -0
  11. package/lib/Operation.js +213 -0
  12. package/lib/Operation.js.map +1 -0
  13. package/lib/OperationError.d.ts +12 -0
  14. package/lib/OperationError.d.ts.map +1 -0
  15. package/lib/OperationError.js +29 -0
  16. package/lib/OperationError.js.map +1 -0
  17. package/lib/OperationExecutionManager.d.ts +46 -0
  18. package/lib/OperationExecutionManager.d.ts.map +1 -0
  19. package/lib/OperationExecutionManager.js +127 -0
  20. package/lib/OperationExecutionManager.js.map +1 -0
  21. package/lib/OperationGroupRecord.d.ts +25 -0
  22. package/lib/OperationGroupRecord.d.ts.map +1 -0
  23. package/lib/OperationGroupRecord.js +65 -0
  24. package/lib/OperationGroupRecord.js.map +1 -0
  25. package/lib/OperationStatus.d.ts +39 -0
  26. package/lib/OperationStatus.d.ts.map +1 -0
  27. package/lib/OperationStatus.js +45 -0
  28. package/lib/OperationStatus.js.map +1 -0
  29. package/lib/Stopwatch.d.ts +47 -0
  30. package/lib/Stopwatch.d.ts.map +1 -0
  31. package/lib/Stopwatch.js +97 -0
  32. package/lib/Stopwatch.js.map +1 -0
  33. package/lib/WatchLoop.d.ts +80 -0
  34. package/lib/WatchLoop.d.ts.map +1 -0
  35. package/lib/WatchLoop.js +191 -0
  36. package/lib/WatchLoop.js.map +1 -0
  37. package/lib/calculateCriticalPath.d.ts +22 -0
  38. package/lib/calculateCriticalPath.d.ts.map +1 -0
  39. package/lib/calculateCriticalPath.js +89 -0
  40. package/lib/calculateCriticalPath.js.map +1 -0
  41. package/lib/index.d.ts +10 -0
  42. package/lib/index.d.ts.map +1 -0
  43. package/lib/index.js +20 -0
  44. package/lib/index.js.map +1 -0
  45. package/lib/protocol.types.d.ts +80 -0
  46. package/lib/protocol.types.d.ts.map +1 -0
  47. package/lib/protocol.types.js +5 -0
  48. package/lib/protocol.types.js.map +1 -0
  49. package/package.json +36 -0
package/LICENSE ADDED
@@ -0,0 +1,24 @@
1
+ @rushstack/operation-graph
2
+
3
+ Copyright (c) Microsoft Corporation. All rights reserved.
4
+
5
+ MIT License
6
+
7
+ Permission is hereby granted, free of charge, to any person obtaining
8
+ a copy of this software and associated documentation files (the
9
+ "Software"), to deal in the Software without restriction, including
10
+ without limitation the rights to use, copy, modify, merge, publish,
11
+ distribute, sublicense, and/or sell copies of the Software, and to
12
+ permit persons to whom the Software is furnished to do so, subject to
13
+ the following conditions:
14
+
15
+ The above copyright notice and this permission notice shall be
16
+ included in all copies or substantial portions of the Software.
17
+
18
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
19
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
20
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
21
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
22
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
23
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
24
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,12 @@
1
+ # @rushstack/operation-graph
2
+
3
+ This library contains logic for managing and executing tasks in a directed acyclic graph. It supports single execution or executing in a loop.
4
+
5
+ ## Links
6
+
7
+ - [CHANGELOG.md](
8
+ https://github.com/microsoft/rushstack/blob/main/libraries/operation-graph/CHANGELOG.md) - Find
9
+ out what's new in the latest version
10
+ - [API Reference](https://rushstack.io/pages/api/operation-graph/)
11
+
12
+ `@rushstack/operation-graph` is part of the [Rush Stack](https://rushstack.io/) family of projects.
@@ -0,0 +1,572 @@
1
+ /// <reference types="node" />
2
+
3
+ import { ITerminal } from '@rushstack/node-core-library';
4
+
5
+ /**
6
+ * The set of known messages from the host to the watch loop.
7
+ * @beta
8
+ */
9
+ export declare type CommandMessageFromHost = ICancelCommandMessage | IExitCommandMessage | IRunCommandMessage | ISyncCommandMessage;
10
+
11
+ /**
12
+ * The set of known messages from the watch loop to the host.
13
+ * @beta
14
+ */
15
+ export declare type EventMessageFromClient = IRequestRunEventMessage | IAfterExecuteEventMessage | ISyncEventMessage;
16
+
17
+ /**
18
+ * A message sent to the host upon completion of a run of this task.
19
+ *
20
+ * @beta
21
+ */
22
+ export declare interface IAfterExecuteEventMessage {
23
+ event: 'after-execute';
24
+ status: OperationStatus;
25
+ }
26
+
27
+ /**
28
+ * A message sent by the host to tell the watch loop to cancel the current run.
29
+ *
30
+ * @beta
31
+ */
32
+ export declare interface ICancelCommandMessage {
33
+ command: 'cancel';
34
+ }
35
+
36
+ /**
37
+ * Information provided to `executeAsync` by the `OperationExecutionManager`.
38
+ *
39
+ * @beta
40
+ */
41
+ export declare interface IExecuteOperationContext extends Omit<IOperationRunnerContext, 'isFirstRun' | 'requestRun'> {
42
+ /**
43
+ * Function to invoke before execution of an operation, for logging.
44
+ */
45
+ beforeExecute(operation: Operation, state: IOperationState): void;
46
+ /**
47
+ * Function to invoke after execution of an operation, for logging.
48
+ */
49
+ afterExecute(operation: Operation, state: IOperationState): void;
50
+ /**
51
+ * Function used to schedule the concurrency-limited execution of an operation.
52
+ */
53
+ queueWork<T>(workFn: () => Promise<T>, priority: number): Promise<T>;
54
+ /**
55
+ * A callback to the overarching orchestrator to request that the operation be invoked again.
56
+ * Used in watch mode to signal that inputs have changed.
57
+ */
58
+ requestRun?: (requestor?: string) => void;
59
+ /**
60
+ * Terminal to write output to.
61
+ */
62
+ terminal: ITerminal;
63
+ }
64
+
65
+ /**
66
+ * A message sent by the host to tell the watch loop to shutdown gracefully.
67
+ *
68
+ * @beta
69
+ */
70
+ export declare interface IExitCommandMessage {
71
+ command: 'exit';
72
+ }
73
+
74
+ /**
75
+ * Options for the current run.
76
+ *
77
+ * @beta
78
+ */
79
+ export declare interface IOperationExecutionOptions {
80
+ abortSignal: AbortSignal;
81
+ parallelism: number;
82
+ terminal: ITerminal;
83
+ requestRun?: (requestor?: string) => void;
84
+ }
85
+
86
+ /**
87
+ * Options for constructing a new Operation.
88
+ * @beta
89
+ */
90
+ export declare interface IOperationOptions {
91
+ /**
92
+ * The name of this operation, for logging.
93
+ */
94
+ name?: string | undefined;
95
+ /**
96
+ * The group that this operation belongs to. Will be used for logging and duration tracking.
97
+ */
98
+ groupName?: string | undefined;
99
+ /**
100
+ * When the scheduler is ready to process this `Operation`, the `runner` implements the actual work of
101
+ * running the operation.
102
+ */
103
+ runner?: IOperationRunner | undefined;
104
+ /**
105
+ * The weight used by the scheduler to determine order of execution.
106
+ */
107
+ weight?: number | undefined;
108
+ }
109
+
110
+ /**
111
+ * The `Operation` class is a node in the dependency graph of work that needs to be scheduled by the
112
+ * `OperationExecutionManager`. Each `Operation` has a `runner` member of type `IOperationRunner`, whose
113
+ * implementation manages the actual process for running a single operation.
114
+ *
115
+ * @beta
116
+ */
117
+ export declare interface IOperationRunner {
118
+ /**
119
+ * Name of the operation, for logging.
120
+ */
121
+ readonly name: string;
122
+ /**
123
+ * Indicates that this runner is architectural and should not be reported on.
124
+ */
125
+ silent: boolean;
126
+ /**
127
+ * Method to be executed for the operation.
128
+ */
129
+ executeAsync(context: IOperationRunnerContext): Promise<OperationStatus>;
130
+ }
131
+
132
+ /**
133
+ * Information passed to the executing `IOperationRunner`
134
+ *
135
+ * @beta
136
+ */
137
+ export declare interface IOperationRunnerContext {
138
+ /**
139
+ * An abort signal for the overarching execution. Runners should do their best to gracefully abort
140
+ * as soon as possible if the signal is aborted.
141
+ */
142
+ abortSignal: AbortSignal;
143
+ /**
144
+ * If this is the first time this operation has been executed.
145
+ */
146
+ isFirstRun: boolean;
147
+ /**
148
+ * A callback to the overarching orchestrator to request that the operation be invoked again.
149
+ * Used in watch mode to signal that inputs have changed.
150
+ */
151
+ requestRun?: () => void;
152
+ }
153
+
154
+ /**
155
+ * Interface contract for a single state of an operation.
156
+ *
157
+ * @beta
158
+ */
159
+ export declare interface IOperationState {
160
+ /**
161
+ * The status code for the operation.
162
+ */
163
+ status: OperationStatus;
164
+ /**
165
+ * Whether the operation has been run at least once.
166
+ */
167
+ hasBeenRun: boolean;
168
+ /**
169
+ * The error, if the status is `OperationStatus.Failure`.
170
+ */
171
+ error: OperationError | undefined;
172
+ /**
173
+ * Timing information for the operation.
174
+ */
175
+ stopwatch: Stopwatch;
176
+ }
177
+
178
+ /**
179
+ * Interface contract for the current and past state of an operation.
180
+ *
181
+ * @beta
182
+ */
183
+ export declare interface IOperationStates {
184
+ /**
185
+ * The current state of the operation.
186
+ */
187
+ readonly state: Readonly<IOperationState> | undefined;
188
+ /**
189
+ * The previous state of the operation.
190
+ */
191
+ readonly lastState: Readonly<IOperationState> | undefined;
192
+ }
193
+
194
+ /**
195
+ * The interface contract for IPC send/receive, to support alternate channels and unit tests.
196
+ *
197
+ * @beta
198
+ */
199
+ export declare type IPCHost = Pick<typeof process, 'on' | 'send'>;
200
+
201
+ /**
202
+ * A message sent to the host to ask it to run this task.
203
+ *
204
+ * @beta
205
+ */
206
+ export declare interface IRequestRunEventMessage {
207
+ event: 'requestRun';
208
+ requestor?: string;
209
+ }
210
+
211
+ /**
212
+ * A message sent by the host to tell the watch loop to perform a single run.
213
+ *
214
+ * @beta
215
+ */
216
+ export declare interface IRunCommandMessage {
217
+ command: 'run';
218
+ }
219
+
220
+ /**
221
+ * A message sent by the host to ask for to resync status information.
222
+ *
223
+ * @beta
224
+ */
225
+ export declare interface ISyncCommandMessage {
226
+ command: 'sync';
227
+ }
228
+
229
+ /**
230
+ * A message sent to the host upon connection of the channel, to indicate
231
+ * to the host that this task supports the protocol and to provide baseline status information.
232
+ *
233
+ * @beta
234
+ */
235
+ export declare interface ISyncEventMessage {
236
+ event: 'sync';
237
+ status: OperationStatus;
238
+ }
239
+
240
+ /**
241
+ * Callbacks for the watch loop.
242
+ *
243
+ * @beta
244
+ */
245
+ export declare interface IWatchLoopOptions {
246
+ /**
247
+ * Callback that performs the core work of a single iteration.
248
+ */
249
+ executeAsync: (state: IWatchLoopState) => Promise<OperationStatus>;
250
+ /**
251
+ * Logging callback immediately before execution occurs.
252
+ */
253
+ onBeforeExecute: () => void;
254
+ /**
255
+ * Logging callback when a run is requested (and hasn't already been).
256
+ */
257
+ onRequestRun: (requestor?: string) => void;
258
+ /**
259
+ * Logging callback when a run is aborted.
260
+ */
261
+ onAbort: () => void;
262
+ }
263
+
264
+ /**
265
+ * The public API surface of the watch loop, for use in the `executeAsync` callback.
266
+ *
267
+ * @beta
268
+ */
269
+ export declare interface IWatchLoopState {
270
+ get abortSignal(): AbortSignal;
271
+ requestRun: (requestor?: string) => void;
272
+ }
273
+
274
+ /**
275
+ * The `Operation` class is a node in the dependency graph of work that needs to be scheduled by the
276
+ * `OperationExecutionManager`. Each `Operation` has a `runner` member of type `IOperationRunner`, whose
277
+ * implementation manages the actual process of running a single operation.
278
+ *
279
+ * The graph of `Operation` instances will be cloned into a separate execution graph after processing.
280
+ *
281
+ * @beta
282
+ */
283
+ export declare class Operation implements IOperationStates {
284
+ /**
285
+ * A set of all dependencies which must be executed before this operation is complete.
286
+ */
287
+ readonly dependencies: Set<Operation>;
288
+ /**
289
+ * A set of all operations that wait for this operation.
290
+ */
291
+ readonly consumers: Set<Operation>;
292
+ /**
293
+ * If specified, the name of a grouping to which this Operation belongs, for logging start and end times.
294
+ */
295
+ readonly groupName: string | undefined;
296
+ /**
297
+ * The name of this operation, for logging.
298
+ */
299
+ readonly name: string | undefined;
300
+ /**
301
+ * When the scheduler is ready to process this `Operation`, the `runner` implements the actual work of
302
+ * running the operation.
303
+ */
304
+ runner: IOperationRunner | undefined;
305
+ /**
306
+ * This number represents how far away this Operation is from the furthest "root" operation (i.e.
307
+ * an operation with no consumers). This helps us to calculate the critical path (i.e. the
308
+ * longest chain of projects which must be executed in order, thereby limiting execution speed
309
+ * of the entire operation tree.
310
+ *
311
+ * This number is calculated via a memoized depth-first search, and when choosing the next
312
+ * operation to execute, the operation with the highest criticalPathLength is chosen.
313
+ *
314
+ * Example:
315
+ * (0) A
316
+ * \\
317
+ * (1) B C (0) (applications)
318
+ * \\ /|\\
319
+ * \\ / | \\
320
+ * (2) D | X (1) (utilities)
321
+ * | / \\
322
+ * |/ \\
323
+ * (2) Y Z (2) (other utilities)
324
+ *
325
+ * All roots (A & C) have a criticalPathLength of 0.
326
+ * B has a score of 1, since A depends on it.
327
+ * D has a score of 2, since we look at the longest chain (e.g D-\>B-\>A is longer than D-\>C)
328
+ * X has a score of 1, since the only package which depends on it is A
329
+ * Z has a score of 2, since only X depends on it, and X has a score of 1
330
+ * Y has a score of 2, since the chain Y-\>X-\>C is longer than Y-\>C
331
+ *
332
+ * The algorithm is implemented in AsyncOperationQueue.ts as calculateCriticalPathLength()
333
+ */
334
+ criticalPathLength: number | undefined;
335
+ /**
336
+ * The weight for this operation. This scalar is the contribution of this operation to the
337
+ * `criticalPathLength` calculation above. Modify to indicate the following:
338
+ * - `weight` === 1: indicates that this operation has an average duration
339
+ * - `weight` &gt; 1: indicates that this operation takes longer than average and so the scheduler
340
+ * should try to favor starting it over other, shorter operations. An example might be an operation that
341
+ * bundles an entire application and runs whole-program optimization.
342
+ * - `weight` &lt; 1: indicates that this operation takes less time than average and so the scheduler
343
+ * should favor other, longer operations over it. An example might be an operation to unpack a cached
344
+ * output, or an operation using NullOperationRunner, which might use a value of 0.
345
+ */
346
+ weight: number;
347
+ /**
348
+ * The state of this operation the previous time a manager was invoked.
349
+ */
350
+ lastState: IOperationState | undefined;
351
+ /**
352
+ * The current state of this operation
353
+ */
354
+ state: IOperationState | undefined;
355
+ /**
356
+ * A cached execution promise for the current OperationExecutionManager invocation of this operation.
357
+ */
358
+ private _promise;
359
+ /**
360
+ * If true, then a run of this operation is currently wanted.
361
+ * This is used to track state from the `requestRun` callback passed to the runner.
362
+ */
363
+ private _runPending;
364
+ constructor(options?: IOperationOptions);
365
+ addDependency(dependency: Operation): void;
366
+ deleteDependency(dependency: Operation): void;
367
+ reset(): void;
368
+ /**
369
+ * @internal
370
+ */
371
+ _executeAsync(context: IExecuteOperationContext): Promise<OperationStatus>;
372
+ private _executeInnerAsync;
373
+ }
374
+
375
+ /**
376
+ * Encapsulates information about an error
377
+ *
378
+ * @beta
379
+ */
380
+ export declare class OperationError extends Error {
381
+ protected _type: string;
382
+ constructor(type: string, message: string);
383
+ get message(): string;
384
+ toString(): string;
385
+ }
386
+
387
+ /**
388
+ * A class which manages the execution of a set of tasks with interdependencies.
389
+ * Initially, and at the end of each task execution, all unblocked tasks
390
+ * are added to a ready queue which is then executed. This is done continually until all
391
+ * tasks are complete, or prematurely fails if any of the tasks fail.
392
+ *
393
+ * @beta
394
+ */
395
+ export declare class OperationExecutionManager {
396
+ /**
397
+ * The set of operations that will be executed
398
+ */
399
+ private readonly _operations;
400
+ /**
401
+ * Group records are metadata-only entities used for tracking the start and end of a set of related tasks.
402
+ * This is the only extent to which the operation graph is aware of Heft phases.
403
+ */
404
+ private readonly _groupRecordByName;
405
+ /**
406
+ * The total number of non-silent operations in the graph.
407
+ * Silent operations are generally used to simplify the construction of the graph.
408
+ */
409
+ private readonly _trackedOperationCount;
410
+ constructor(operations: ReadonlySet<Operation>);
411
+ /**
412
+ * Executes all operations which have been registered, returning a promise which is resolved when all the
413
+ * operations are completed successfully, or rejects when any operation fails.
414
+ */
415
+ executeAsync(executionOptions: IOperationExecutionOptions): Promise<OperationStatus>;
416
+ }
417
+
418
+ /**
419
+ * Meta-entity that tracks information about a group of related operations.
420
+ *
421
+ * @beta
422
+ */
423
+ export declare class OperationGroupRecord {
424
+ private readonly _operations;
425
+ private _remainingOperations;
426
+ private _groupStopwatch;
427
+ private _hasCancellations;
428
+ private _hasFailures;
429
+ readonly name: string;
430
+ get duration(): number;
431
+ get finished(): boolean;
432
+ get hasCancellations(): boolean;
433
+ get hasFailures(): boolean;
434
+ constructor(name: string);
435
+ addOperation(operation: Operation): void;
436
+ startTimer(): void;
437
+ setOperationAsComplete(operation: Operation, state: IOperationState): void;
438
+ reset(): void;
439
+ }
440
+
441
+ /**
442
+ * Enumeration defining potential states of an operation
443
+ * @beta
444
+ */
445
+ export declare enum OperationStatus {
446
+ /**
447
+ * The Operation is on the queue, ready to execute
448
+ */
449
+ Ready = "READY",
450
+ /**
451
+ * The Operation is on the queue, waiting for one or more depencies
452
+ */
453
+ Waiting = "WAITING",
454
+ /**
455
+ * The Operation is currently executing
456
+ */
457
+ Executing = "EXECUTING",
458
+ /**
459
+ * The Operation completed successfully and did not write to standard output
460
+ */
461
+ Success = "SUCCESS",
462
+ /**
463
+ * The Operation failed
464
+ */
465
+ Failure = "FAILURE",
466
+ /**
467
+ * The operation was aborted
468
+ */
469
+ Aborted = "ABORTED",
470
+ /**
471
+ * The Operation could not be executed because one or more of its dependencies failed
472
+ */
473
+ Blocked = "BLOCKED",
474
+ /**
475
+ * The operation performed no meaningful work.
476
+ */
477
+ NoOp = "NO OP"
478
+ }
479
+
480
+ /**
481
+ * Represents a typical timer/stopwatch which keeps track
482
+ * of elapsed time in between two events.
483
+ *
484
+ * @public
485
+ */
486
+ export declare class Stopwatch {
487
+ private _startTime;
488
+ private _endTime;
489
+ private _running;
490
+ constructor();
491
+ /**
492
+ * Static helper function which creates a stopwatch which is immediately started
493
+ */
494
+ static start(): Stopwatch;
495
+ get isRunning(): boolean;
496
+ /**
497
+ * Starts the stopwatch. Note that if end() has been called,
498
+ * reset() should be called before calling start() again.
499
+ */
500
+ start(): Stopwatch;
501
+ /**
502
+ * Stops executing the stopwatch and saves the current timestamp
503
+ */
504
+ stop(): Stopwatch;
505
+ /**
506
+ * Resets all values of the stopwatch back to the original
507
+ */
508
+ reset(): Stopwatch;
509
+ /**
510
+ * Displays how long the stopwatch has been executing in a human readable format.
511
+ */
512
+ toString(): string;
513
+ /**
514
+ * Get the duration in seconds.
515
+ */
516
+ get duration(): number;
517
+ /**
518
+ * Return the start time of the most recent stopwatch run.
519
+ */
520
+ get startTime(): number | undefined;
521
+ /**
522
+ * Return the end time of the most recent stopwatch run.
523
+ */
524
+ get endTime(): number | undefined;
525
+ }
526
+
527
+ /**
528
+ * This class implements a watch loop.
529
+ *
530
+ * @beta
531
+ */
532
+ export declare class WatchLoop implements IWatchLoopState {
533
+ private readonly _options;
534
+ private readonly _outerSignals;
535
+ private _abortController;
536
+ private _isRunning;
537
+ private _runRequested;
538
+ private _requestRunPromise;
539
+ private _resolveRequestRun;
540
+ constructor(options: IWatchLoopOptions);
541
+ /**
542
+ * Runs the inner loop until the abort signal is cancelled or a run completes without a new run being requested.
543
+ */
544
+ runUntilStableAsync(abortSignal: AbortSignal): Promise<OperationStatus>;
545
+ /**
546
+ * Runs the inner loop until the abort signal is aborted. Will otherwise wait indefinitely for a new run to be requested.
547
+ */
548
+ runUntilAbortedAsync(abortSignal: AbortSignal, onWaiting: () => void): Promise<void>;
549
+ /**
550
+ * Sets up an IPC handler that will run the inner loop when it receives a "run" message from the host.
551
+ * Runs until receiving an "exit" message from the host, or aborts early if an unhandled error is thrown.
552
+ */
553
+ runIPCAsync(host?: IPCHost): Promise<void>;
554
+ /**
555
+ * Requests that a new run occur.
556
+ */
557
+ requestRun: (requestor?: string) => void;
558
+ /**
559
+ * The abort signal for the current iteration.
560
+ */
561
+ get abortSignal(): AbortSignal;
562
+ /**
563
+ * Cancels the current iteration (if possible).
564
+ */
565
+ private _abortCurrent;
566
+ /**
567
+ * Resets the abort signal and run request state.
568
+ */
569
+ private _reset;
570
+ }
571
+
572
+ export { }
@@ -0,0 +1,11 @@
1
+ // This file is read by tools that parse documentation comments conforming to the TSDoc standard.
2
+ // It should be published with your NPM package. It should not be tracked by Git.
3
+ {
4
+ "tsdocVersion": "0.12",
5
+ "toolPackages": [
6
+ {
7
+ "packageName": "@microsoft/api-extractor",
8
+ "packageVersion": "7.37.0"
9
+ }
10
+ ]
11
+ }
@@ -0,0 +1,85 @@
1
+ /// <reference types="node" />
2
+ import type { OperationStatus } from './OperationStatus';
3
+ import type { OperationError } from './OperationError';
4
+ import type { Stopwatch } from './Stopwatch';
5
+ /**
6
+ * Information passed to the executing `IOperationRunner`
7
+ *
8
+ * @beta
9
+ */
10
+ export interface IOperationRunnerContext {
11
+ /**
12
+ * An abort signal for the overarching execution. Runners should do their best to gracefully abort
13
+ * as soon as possible if the signal is aborted.
14
+ */
15
+ abortSignal: AbortSignal;
16
+ /**
17
+ * If this is the first time this operation has been executed.
18
+ */
19
+ isFirstRun: boolean;
20
+ /**
21
+ * A callback to the overarching orchestrator to request that the operation be invoked again.
22
+ * Used in watch mode to signal that inputs have changed.
23
+ */
24
+ requestRun?: () => void;
25
+ }
26
+ /**
27
+ * Interface contract for a single state of an operation.
28
+ *
29
+ * @beta
30
+ */
31
+ export interface IOperationState {
32
+ /**
33
+ * The status code for the operation.
34
+ */
35
+ status: OperationStatus;
36
+ /**
37
+ * Whether the operation has been run at least once.
38
+ */
39
+ hasBeenRun: boolean;
40
+ /**
41
+ * The error, if the status is `OperationStatus.Failure`.
42
+ */
43
+ error: OperationError | undefined;
44
+ /**
45
+ * Timing information for the operation.
46
+ */
47
+ stopwatch: Stopwatch;
48
+ }
49
+ /**
50
+ * Interface contract for the current and past state of an operation.
51
+ *
52
+ * @beta
53
+ */
54
+ export interface IOperationStates {
55
+ /**
56
+ * The current state of the operation.
57
+ */
58
+ readonly state: Readonly<IOperationState> | undefined;
59
+ /**
60
+ * The previous state of the operation.
61
+ */
62
+ readonly lastState: Readonly<IOperationState> | undefined;
63
+ }
64
+ /**
65
+ * The `Operation` class is a node in the dependency graph of work that needs to be scheduled by the
66
+ * `OperationExecutionManager`. Each `Operation` has a `runner` member of type `IOperationRunner`, whose
67
+ * implementation manages the actual process for running a single operation.
68
+ *
69
+ * @beta
70
+ */
71
+ export interface IOperationRunner {
72
+ /**
73
+ * Name of the operation, for logging.
74
+ */
75
+ readonly name: string;
76
+ /**
77
+ * Indicates that this runner is architectural and should not be reported on.
78
+ */
79
+ silent: boolean;
80
+ /**
81
+ * Method to be executed for the operation.
82
+ */
83
+ executeAsync(context: IOperationRunnerContext): Promise<OperationStatus>;
84
+ }
85
+ //# sourceMappingURL=IOperationRunner.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"IOperationRunner.d.ts","sourceRoot":"","sources":["../src/IOperationRunner.ts"],"names":[],"mappings":";AAGA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACzD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAEvD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAE7C;;;;GAIG;AACH,MAAM,WAAW,uBAAuB;IACtC;;;OAGG;IACH,WAAW,EAAE,WAAW,CAAC;IAEzB;;OAEG;IACH,UAAU,EAAE,OAAO,CAAC;IAEpB;;;OAGG;IACH,UAAU,CAAC,EAAE,MAAM,IAAI,CAAC;CACzB;AAED;;;;GAIG;AACH,MAAM,WAAW,eAAe;IAC9B;;OAEG;IACH,MAAM,EAAE,eAAe,CAAC;IACxB;;OAEG;IACH,UAAU,EAAE,OAAO,CAAC;IACpB;;OAEG;IACH,KAAK,EAAE,cAAc,GAAG,SAAS,CAAC;IAClC;;OAEG;IACH,SAAS,EAAE,SAAS,CAAC;CACtB;AAED;;;;GAIG;AACH,MAAM,WAAW,gBAAgB;IAC/B;;OAEG;IACH,QAAQ,CAAC,KAAK,EAAE,QAAQ,CAAC,eAAe,CAAC,GAAG,SAAS,CAAC;IACtD;;OAEG;IACH,QAAQ,CAAC,SAAS,EAAE,QAAQ,CAAC,eAAe,CAAC,GAAG,SAAS,CAAC;CAC3D;AAED;;;;;;GAMG;AACH,MAAM,WAAW,gBAAgB;IAC/B;;OAEG;IACH,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAEtB;;OAEG;IACH,MAAM,EAAE,OAAO,CAAC;IAEhB;;OAEG;IACH,YAAY,CAAC,OAAO,EAAE,uBAAuB,GAAG,OAAO,CAAC,eAAe,CAAC,CAAC;CAC1E"}