@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
@@ -0,0 +1 @@
1
+ {"version":3,"file":"WatchLoop.js","sourceRoot":"","sources":["../src/WatchLoop.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;;AAE3D,6CAAmC;AAEnC,oEAAoE;AAEpE,uDAAoD;AA2CpD;;;;GAIG;AACH,MAAa,SAAS;IAUpB,YAAmB,OAA0B;QA8J7C;;WAEG;QACI,eAAU,GAAiC,CAAC,SAAkB,EAAE,EAAE;YACvE,IAAI,CAAC,IAAI,CAAC,aAAa,EAAE;gBACvB,IAAI,CAAC,QAAQ,CAAC,YAAY,CAAC,SAAS,CAAC,CAAC;gBACtC,IAAI,CAAC,aAAa,GAAG,IAAI,CAAC;gBAC1B,IAAI,IAAI,CAAC,UAAU,EAAE;oBACnB,IAAI,CAAC,QAAQ,CAAC,OAAO,EAAE,CAAC;oBACxB,IAAI,CAAC,aAAa,EAAE,CAAC;iBACtB;aACF;YACD,IAAI,CAAC,kBAAkB,CAAC,SAAS,CAAC,CAAC;QACrC,CAAC,CAAC;QASF;;WAEG;QACK,kBAAa,GAAG,GAAS,EAAE;YACjC,IAAI,CAAC,gBAAgB,CAAC,KAAK,EAAE,CAAC;QAChC,CAAC,CAAC;QAxLA,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAC;QAExB,IAAI,CAAC,gBAAgB,GAAG,IAAI,eAAe,EAAE,CAAC;QAC9C,IAAI,CAAC,UAAU,GAAG,KAAK,CAAC;QACxB,8EAA8E;QAC9E,IAAI,CAAC,aAAa,GAAG,IA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AC;IACtC,CAAC;IASD;;OAEG;IACK,MAAM;QACZ,IAAI,IAAI,CAAC,gBAAgB,CAAC,MAAM,CAAC,OAAO,EAAE;YACxC,IAAI,CAAC,gBAAgB,GAAG,IAAI,eAAe,EAAE,CAAC;SAC/C;QAED,IAAI,IAAI,CAAC,aAAa,EAAE;YACtB,IAAI,CAAC,aAAa,GAAG,KAAK,CAAC;YAC3B,IAAI,CAAC,kBAAkB,GAAG,IAAI,OAAO,CAAqB,CAAC,OAAO,EAAE,EAAE;gBACpE,IAAI,CAAC,kBAAkB,GAAG,OAAO,CAAC;YACpC,CAAC,CAAC,CAAC;SACJ;IACH,CAAC;CACF;AApND,8BAoNC","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.\n// See LICENSE in the project root for license information.\n\nimport { once } from 'node:events';\n\nimport { AlreadyReportedError } from '@rushstack/node-core-library';\n\nimport { OperationStatus } from './OperationStatus';\nimport type {\n IAfterExecuteEventMessage,\n IPCHost,\n CommandMessageFromHost,\n ISyncEventMessage,\n IRequestRunEventMessage\n} from './protocol.types';\n\n/**\n * Callbacks for the watch loop.\n *\n * @beta\n */\nexport interface IWatchLoopOptions {\n /**\n * Callback that performs the core work of a single iteration.\n */\n executeAsync: (state: IWatchLoopState) => Promise<OperationStatus>;\n /**\n * Logging callback immediately before execution occurs.\n */\n onBeforeExecute: () => void;\n /**\n * Logging callback when a run is requested (and hasn't already been).\n */\n onRequestRun: (requestor?: string) => void;\n /**\n * Logging callback when a run is aborted.\n */\n onAbort: () => void;\n}\n\n/**\n * The public API surface of the watch loop, for use in the `executeAsync` callback.\n *\n * @beta\n */\nexport interface IWatchLoopState {\n get abortSignal(): AbortSignal;\n requestRun: (requestor?: string) => void;\n}\n\n/**\n * This class implements a watch loop.\n *\n * @beta\n */\nexport class WatchLoop implements IWatchLoopState {\n private readonly _options: Readonly<IWatchLoopOptions>;\n private readonly _outerSignals: WeakSet<AbortSignal>;\n\n private _abortController: AbortController;\n private _isRunning: boolean;\n private _runRequested: boolean;\n private _requestRunPromise: Promise<string | undefined>;\n private _resolveRequestRun!: (requestor?: string) => void;\n\n public constructor(options: IWatchLoopOptions) {\n this._options = options;\n\n this._abortController = new AbortController();\n this._isRunning = false;\n // Always start as true, so that any requests prior to first run are silenced.\n this._runRequested = true;\n this._requestRunPromise = new Promise<string | undefined>((resolve) => {\n this._resolveRequestRun = resolve;\n });\n\n this._outerSignals = new WeakSet();\n }\n\n /**\n * Runs the inner loop until the abort signal is cancelled or a run completes without a new run being requested.\n */\n public async runUntilStableAsync(abortSignal: AbortSignal): Promise<OperationStatus> {\n if (abortSignal.aborted) {\n return OperationStatus.Aborted;\n }\n\n if (!this._outerSignals.has(abortSignal)) {\n once(abortSignal, 'abort').finally(this._abortCurrent);\n }\n\n let result: OperationStatus = OperationStatus.Ready;\n\n do {\n // Always check the abort signal first, in case it was aborted in the async tick since the last executeAsync() call.\n if (abortSignal.aborted) {\n return OperationStatus.Aborted;\n }\n\n this._reset();\n\n this._options.onBeforeExecute();\n try {\n this._isRunning = true;\n result = await this._options.executeAsync(this);\n } catch (err) {\n if (!(err instanceof AlreadyReportedError)) {\n throw err;\n } else {\n result = OperationStatus.Failure;\n }\n } finally {\n this._isRunning = false;\n }\n } while (this._runRequested);\n\n // Even if the run has finished, if the abort signal was aborted, we should return `Aborted` just in case.\n return abortSignal.aborted ? OperationStatus.Aborted : result;\n }\n\n /**\n * Runs the inner loop until the abort signal is aborted. Will otherwise wait indefinitely for a new run to be requested.\n */\n public async runUntilAbortedAsync(abortSignal: AbortSignal, onWaiting: () => void): Promise<void> {\n if (abortSignal.aborted) {\n return;\n }\n\n const abortPromise: Promise<unknown> = once(abortSignal, 'abort');\n\n // eslint-disable-next-line no-constant-condition\n while (!abortSignal.aborted) {\n await this.runUntilStableAsync(abortSignal);\n\n onWaiting();\n await Promise.race([this._requestRunPromise, abortPromise]);\n }\n }\n\n /**\n * Sets up an IPC handler that will run the inner loop when it receives a \"run\" message from the host.\n * Runs until receiving an \"exit\" message from the host, or aborts early if an unhandled error is thrown.\n */\n public async runIPCAsync(host: IPCHost = process): Promise<void> {\n await new Promise<void>((resolve, reject) => {\n let abortController: AbortController = new AbortController();\n\n let runRequestedFromHost: boolean = true;\n let status: OperationStatus = OperationStatus.Ready;\n\n function requestRunFromHost(requestor?: string): void {\n if (runRequestedFromHost) {\n return;\n }\n\n runRequestedFromHost = true;\n\n const requestRunMessage: IRequestRunEventMessage = {\n event: 'requestRun',\n requestor\n };\n\n host.send!(requestRunMessage);\n }\n\n function sendSync(): void {\n const syncMessage: ISyncEventMessage = {\n event: 'sync',\n status\n };\n host.send!(syncMessage);\n }\n\n host.on('message', async (message: CommandMessageFromHost) => {\n switch (message.command) {\n case 'exit': {\n return resolve();\n }\n\n case 'cancel': {\n if (this._isRunning) {\n abortController.abort();\n abortController = new AbortController();\n // This will terminate the currently executing `runUntilStableAsync` call.\n }\n return;\n }\n\n case 'run': {\n runRequestedFromHost = false;\n\n status = OperationStatus.Executing;\n\n try {\n status = await this.runUntilStableAsync(abortController.signal);\n this._requestRunPromise.finally(requestRunFromHost);\n } catch (err) {\n status = OperationStatus.Failure;\n return reject(err);\n } finally {\n const afterExecuteMessage: IAfterExecuteEventMessage = {\n event: 'after-execute',\n status\n };\n host.send!(afterExecuteMessage);\n }\n return;\n }\n\n case 'sync': {\n return sendSync();\n }\n\n default: {\n return reject(new Error(`Unexpected command from host: ${message}`));\n }\n }\n });\n\n sendSync();\n });\n }\n\n /**\n * Requests that a new run occur.\n */\n public requestRun: (requestor?: string) => void = (requestor?: string) => {\n if (!this._runRequested) {\n this._options.onRequestRun(requestor);\n this._runRequested = true;\n if (this._isRunning) {\n this._options.onAbort();\n this._abortCurrent();\n }\n }\n this._resolveRequestRun(requestor);\n };\n\n /**\n * The abort signal for the current iteration.\n */\n public get abortSignal(): AbortSignal {\n return this._abortController.signal;\n }\n\n /**\n * Cancels the current iteration (if possible).\n */\n private _abortCurrent = (): void => {\n this._abortController.abort();\n };\n\n /**\n * Resets the abort signal and run request state.\n */\n private _reset(): void {\n if (this._abortController.signal.aborted) {\n this._abortController = new AbortController();\n }\n\n if (this._runRequested) {\n this._runRequested = false;\n this._requestRunPromise = new Promise<string | undefined>((resolve) => {\n this._resolveRequestRun = resolve;\n });\n }\n }\n}\n"]}
@@ -0,0 +1,22 @@
1
+ export interface ISortableOperation<T extends ISortableOperation<T>> {
2
+ name: string | undefined;
3
+ criticalPathLength?: number | undefined;
4
+ weight: number;
5
+ consumers: Set<T>;
6
+ }
7
+ /**
8
+ * For every operation in the input, computes the length of the longest chain of operations that depend on it.
9
+ * This value is stored as `operation.criticalPathLength`.
10
+ */
11
+ export declare function calculateCriticalPathLengths<T extends ISortableOperation<T>>(operations: Iterable<T>): T[];
12
+ /**
13
+ * Calculates the shortest path from `startOperation` to `endOperation`.
14
+ * Used when printing out circular dependencies.
15
+ */
16
+ export declare function calculateShortestPath<T extends ISortableOperation<T>>(startOperation: T, endOperation: T): T[];
17
+ /**
18
+ * Perform a depth-first search to find critical path length to the provided operation.
19
+ * Cycle detection comes at minimal additional cost.
20
+ */
21
+ export declare function calculateCriticalPathLength<T extends ISortableOperation<T>>(operation: T, dependencyChain: Set<T>): number;
22
+ //# sourceMappingURL=calculateCriticalPath.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"calculateCriticalPath.d.ts","sourceRoot":"","sources":["../src/calculateCriticalPath.ts"],"names":[],"mappings":"AAGA,MAAM,WAAW,kBAAkB,CAAC,CAAC,SAAS,kBAAkB,CAAC,CAAC,CAAC;IACjE,IAAI,EAAE,MAAM,GAAG,SAAS,CAAC;IACzB,kBAAkB,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IACxC,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,GAAG,CAAC,CAAC,CAAC,CAAC;CACnB;AAED;;;GAGG;AACH,wBAAgB,4BAA4B,CAAC,CAAC,SAAS,kBAAkB,CAAC,CAAC,CAAC,EAAE,UAAU,EAAE,QAAQ,CAAC,CAAC,CAAC,GAAG,CAAC,EAAE,CAW1G;AAED;;;GAGG;AACH,wBAAgB,qBAAqB,CAAC,CAAC,SAAS,kBAAkB,CAAC,CAAC,CAAC,EACnE,cAAc,EAAE,CAAC,EACjB,YAAY,EAAE,CAAC,GACd,CAAC,EAAE,CAiCL;AAED;;;GAGG;AACH,wBAAgB,2BAA2B,CAAC,CAAC,SAAS,kBAAkB,CAAC,CAAC,CAAC,EACzE,SAAS,EAAE,CAAC,EACZ,eAAe,EAAE,GAAG,CAAC,CAAC,CAAC,GACtB,MAAM,CAuCR"}
@@ -0,0 +1,89 @@
1
+ "use strict";
2
+ // Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
3
+ // See LICENSE in the project root for license information.
4
+ Object.defineProperty(exports, "__esModule", { value: true });
5
+ exports.calculateCriticalPathLength = exports.calculateShortestPath = exports.calculateCriticalPathLengths = void 0;
6
+ /**
7
+ * For every operation in the input, computes the length of the longest chain of operations that depend on it.
8
+ * This value is stored as `operation.criticalPathLength`.
9
+ */
10
+ function calculateCriticalPathLengths(operations) {
11
+ // Clone the set of operations as an array, so that we can sort it.
12
+ const queue = Array.from(operations);
13
+ // Create a collection for detecting visited nodes
14
+ const cycleDetectorStack = new Set();
15
+ for (const operation of queue) {
16
+ calculateCriticalPathLength(operation, cycleDetectorStack);
17
+ }
18
+ return queue;
19
+ }
20
+ exports.calculateCriticalPathLengths = calculateCriticalPathLengths;
21
+ /**
22
+ * Calculates the shortest path from `startOperation` to `endOperation`.
23
+ * Used when printing out circular dependencies.
24
+ */
25
+ function calculateShortestPath(startOperation, endOperation) {
26
+ // Map of each operation to the most optimal parent
27
+ const parents = new Map([[endOperation, undefined]]);
28
+ let finalParent;
29
+ // Run a breadth-first search to find the shortest path between the start and end operations
30
+ outer: for (const [operation] of parents) {
31
+ for (const consumer of operation.consumers) {
32
+ // Since this is a breadth-first traversal, the first encountered path to a given node
33
+ // will be tied for shortest, so only the first encountered path needs to be tracked
34
+ if (!parents.has(consumer)) {
35
+ parents.set(consumer, operation);
36
+ }
37
+ if (consumer === startOperation) {
38
+ finalParent = operation;
39
+ break outer;
40
+ }
41
+ }
42
+ }
43
+ if (!finalParent) {
44
+ throw new Error(`Could not find a path from "${startOperation.name}" to "${endOperation.name}"`);
45
+ }
46
+ // Walk back up the path from the end operation to the start operation
47
+ let currentOperation = finalParent;
48
+ const path = [startOperation];
49
+ while (currentOperation !== undefined) {
50
+ path.push(currentOperation);
51
+ currentOperation = parents.get(currentOperation);
52
+ }
53
+ return path;
54
+ }
55
+ exports.calculateShortestPath = calculateShortestPath;
56
+ /**
57
+ * Perform a depth-first search to find critical path length to the provided operation.
58
+ * Cycle detection comes at minimal additional cost.
59
+ */
60
+ function calculateCriticalPathLength(operation, dependencyChain) {
61
+ if (dependencyChain.has(operation)) {
62
+ // Ensure we have the shortest path to the cycle
63
+ const shortestPath = calculateShortestPath(operation, operation);
64
+ throw new Error('A cyclic dependency was encountered:\n ' +
65
+ shortestPath.map((visitedTask) => visitedTask.name).join('\n -> '));
66
+ }
67
+ let { criticalPathLength } = operation;
68
+ if (criticalPathLength !== undefined) {
69
+ // This has been visited already
70
+ return criticalPathLength;
71
+ }
72
+ criticalPathLength = 0;
73
+ if (operation.consumers.size) {
74
+ dependencyChain.add(operation);
75
+ for (const consumer of operation.consumers) {
76
+ criticalPathLength = Math.max(criticalPathLength, calculateCriticalPathLength(consumer, dependencyChain));
77
+ }
78
+ dependencyChain.delete(operation);
79
+ }
80
+ // Include the contribution from the current operation
81
+ criticalPathLength += operation.weight ?? 1;
82
+ // Record result
83
+ operation.criticalPathLength = criticalPathLength;
84
+ // Directly writing operations to an output collection here would yield a topological sorted set
85
+ // However, we want a bit more fine-tuning of the output than just the raw topology
86
+ return criticalPathLength;
87
+ }
88
+ exports.calculateCriticalPathLength = calculateCriticalPathLength;
89
+ //# sourceMappingURL=calculateCriticalPath.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"calculateC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GAAG,kBAAkB,CAAC;IAElD,gGAAgG;IAChG,mFAAmF;IAEnF,OAAO,kBAAkB,CAAC;AAC5B,CAAC;AA1CD,kEA0CC","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.\n// See LICENSE in the project root for license information.\n\nexport interface ISortableOperation<T extends ISortableOperation<T>> {\n name: string | undefined;\n criticalPathLength?: number | undefined;\n weight: number;\n consumers: Set<T>;\n}\n\n/**\n * For every operation in the input, computes the length of the longest chain of operations that depend on it.\n * This value is stored as `operation.criticalPathLength`.\n */\nexport function calculateCriticalPathLengths<T extends ISortableOperation<T>>(operations: Iterable<T>): T[] {\n // Clone the set of operations as an array, so that we can sort it.\n const queue: T[] = Array.from(operations);\n\n // Create a collection for detecting visited nodes\n const cycleDetectorStack: Set<T> = new Set();\n for (const operation of queue) {\n calculateCriticalPathLength(operation, cycleDetectorStack);\n }\n\n return queue;\n}\n\n/**\n * Calculates the shortest path from `startOperation` to `endOperation`.\n * Used when printing out circular dependencies.\n */\nexport function calculateShortestPath<T extends ISortableOperation<T>>(\n startOperation: T,\n endOperation: T\n): T[] {\n // Map of each operation to the most optimal parent\n const parents: Map<T, T | undefined> = new Map([[endOperation, undefined]]);\n let finalParent: T | undefined;\n\n // Run a breadth-first search to find the shortest path between the start and end operations\n outer: for (const [operation] of parents) {\n for (const consumer of operation.consumers) {\n // Since this is a breadth-first traversal, the first encountered path to a given node\n // will be tied for shortest, so only the first encountered path needs to be tracked\n if (!parents.has(consumer)) {\n parents.set(consumer, operation);\n }\n\n if (consumer === startOperation) {\n finalParent = operation;\n break outer;\n }\n }\n }\n\n if (!finalParent) {\n throw new Error(`Could not find a path from \"${startOperation.name}\" to \"${endOperation.name}\"`);\n }\n\n // Walk back up the path from the end operation to the start operation\n let currentOperation: T = finalParent;\n const path: T[] = [startOperation];\n while (currentOperation !== undefined) {\n path.push(currentOperation);\n currentOperation = parents.get(currentOperation)!;\n }\n return path;\n}\n\n/**\n * Perform a depth-first search to find critical path length to the provided operation.\n * Cycle detection comes at minimal additional cost.\n */\nexport function calculateCriticalPathLength<T extends ISortableOperation<T>>(\n operation: T,\n dependencyChain: Set<T>\n): number {\n if (dependencyChain.has(operation)) {\n // Ensure we have the shortest path to the cycle\n const shortestPath: T[] = calculateShortestPath(operation, operation);\n\n throw new Error(\n 'A cyclic dependency was encountered:\\n ' +\n shortestPath.map((visitedTask) => visitedTask.name).join('\\n -> ')\n );\n }\n\n let { criticalPathLength } = operation;\n\n if (criticalPathLength !== undefined) {\n // This has been visited already\n return criticalPathLength;\n }\n\n criticalPathLength = 0;\n if (operation.consumers.size) {\n dependencyChain.add(operation);\n for (const consumer of operation.consumers) {\n criticalPathLength = Math.max(\n criticalPathLength,\n calculateCriticalPathLength(consumer, dependencyChain)\n );\n }\n dependencyChain.delete(operation);\n }\n // Include the contribution from the current operation\n criticalPathLength += operation.weight ?? 1;\n\n // Record result\n operation.criticalPathLength = criticalPathLength;\n\n // Directly writing operations to an output collection here would yield a topological sorted set\n // However, we want a bit more fine-tuning of the output than just the raw topology\n\n return criticalPathLength;\n}\n"]}
package/lib/index.d.ts ADDED
@@ -0,0 +1,10 @@
1
+ export type { IOperationRunner, IOperationRunnerContext, IOperationState, IOperationStates } from './IOperationRunner';
2
+ export type { IAfterExecuteEventMessage, ISyncEventMessage, IRequestRunEventMessage, EventMessageFromClient, ICancelCommandMessage, IExitCommandMessage, IRunCommandMessage, ISyncCommandMessage, CommandMessageFromHost, IPCHost } from './protocol.types';
3
+ export { type IExecuteOperationContext, type IOperationOptions, Operation } from './Operation';
4
+ export { OperationError } from './OperationError';
5
+ export { type IOperationExecutionOptions, OperationExecutionManager } from './OperationExecutionManager';
6
+ export { OperationGroupRecord } from './OperationGroupRecord';
7
+ export { OperationStatus } from './OperationStatus';
8
+ export { Stopwatch } from './Stopwatch';
9
+ export { type IWatchLoopOptions, type IWatchLoopState, WatchLoop } from './WatchLoop';
10
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAGA,YAAY,EACV,gBAAgB,EAChB,uBAAuB,EACvB,eAAe,EACf,gBAAgB,EACjB,MAAM,oBAAoB,CAAC;AAE5B,YAAY,EACV,yBAAyB,EACzB,iBAAiB,EACjB,uBAAuB,EACvB,sBAAsB,EACtB,qBAAqB,EACrB,mBAAmB,EACnB,kBAAkB,EAClB,mBAAmB,EACnB,sBAAsB,EACtB,OAAO,EACR,MAAM,kBAAkB,CAAC;AAE1B,OAAO,EAAE,KAAK,wBAAwB,EAAE,KAAK,iBAAiB,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAE/F,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAElD,OAAO,EAAE,KAAK,0BAA0B,EAAE,yBAAyB,EAAE,MAAM,6BAA6B,CAAC;AAEzG,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAE9D,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAEpD,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAExC,OAAO,EAAE,KAAK,iBAAiB,EAAE,KAAK,eAAe,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC"}
package/lib/index.js ADDED
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+ // Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
3
+ // See LICENSE in the project root for license information.
4
+ Object.defineProperty(exports, "__esModule", { value: true });
5
+ exports.WatchLoop = exports.Stopwatch = exports.OperationStatus = exports.OperationGroupRecord = exports.OperationExecutionManager = exports.OperationError = exports.Operation = void 0;
6
+ var Operation_1 = require("./Operation");
7
+ Object.defineProperty(exports, "Operation", { enumerable: true, get: function () { return Operation_1.Operation; } });
8
+ var OperationError_1 = require("./OperationError");
9
+ Object.defineProperty(exports, "OperationError", { enumerable: true, get: function () { return OperationError_1.OperationError; } });
10
+ var OperationExecutionManager_1 = require("./OperationExecutionManager");
11
+ Object.defineProperty(exports, "OperationExecutionManager", { enumerable: true, get: function () { return OperationExecutionManager_1.OperationExecutionManager; } });
12
+ var OperationGroupRecord_1 = require("./OperationGroupRecord");
13
+ Object.defineProperty(exports, "OperationGroupRecord", { enumerable: true, get: function () { return OperationGroupRecord_1.OperationGroupRecord; } });
14
+ var OperationStatus_1 = require("./OperationStatus");
15
+ Object.defineProperty(exports, "OperationStatus", { enumerable: true, get: function () { return OperationStatus_1.OperationStatus; } });
16
+ var Stopwatch_1 = require("./Stopwatch");
17
+ Object.defineProperty(exports, "Stopwatch", { enumerable: true, get: function () { return Stopwatch_1.Stopwatch; } });
18
+ var WatchLoop_1 = require("./WatchLoop");
19
+ Object.defineProperty(exports, "WatchLoop", { enumerable: true, get: function () { return WatchLoop_1.WatchLoop; } });
20
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;;AAsB3D,yCAA+F;AAA/B,sGAAA,SAAS,OAAA;AAEzE,mDAAkD;AAAzC,gHAAA,cAAc,OAAA;AAEvB,yEAAyG;AAA/D,sIAAA,yBAAyB,OAAA;AAEnE,+DAA8D;AAArD,4HAAA,oBAAoB,OAAA;AAE7B,qDAAoD;AAA3C,kHAAA,eAAe,OAAA;AAExB,yCAAwC;AAA/B,sGAAA,SAAS,OAAA;AAElB,yCAAsF;AAA/B,sGAAA,SAAS,OAAA","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.\n// See LICENSE in the project root for license information.\n\nexport type {\n IOperationRunner,\n IOperationRunnerContext,\n IOperationState,\n IOperationStates\n} from './IOperationRunner';\n\nexport type {\n IAfterExecuteEventMessage,\n ISyncEventMessage,\n IRequestRunEventMessage,\n EventMessageFromClient,\n ICancelCommandMessage,\n IExitCommandMessage,\n IRunCommandMessage,\n ISyncCommandMessage,\n CommandMessageFromHost,\n IPCHost\n} from './protocol.types';\n\nexport { type IExecuteOperationContext, type IOperationOptions, Operation } from './Operation';\n\nexport { OperationError } from './OperationError';\n\nexport { type IOperationExecutionOptions, OperationExecutionManager } from './OperationExecutionManager';\n\nexport { OperationGroupRecord } from './OperationGroupRecord';\n\nexport { OperationStatus } from './OperationStatus';\n\nexport { Stopwatch } from './Stopwatch';\n\nexport { type IWatchLoopOptions, type IWatchLoopState, WatchLoop } from './WatchLoop';\n"]}
@@ -0,0 +1,80 @@
1
+ /// <reference types="node" />
2
+ /// <reference types="node" />
3
+ import type { OperationStatus } from './OperationStatus';
4
+ /**
5
+ * A message sent to the host to ask it to run this task.
6
+ *
7
+ * @beta
8
+ */
9
+ export interface IRequestRunEventMessage {
10
+ event: 'requestRun';
11
+ requestor?: string;
12
+ }
13
+ /**
14
+ * A message sent to the host upon completion of a run of this task.
15
+ *
16
+ * @beta
17
+ */
18
+ export interface IAfterExecuteEventMessage {
19
+ event: 'after-execute';
20
+ status: OperationStatus;
21
+ }
22
+ /**
23
+ * A message sent to the host upon connection of the channel, to indicate
24
+ * to the host that this task supports the protocol and to provide baseline status information.
25
+ *
26
+ * @beta
27
+ */
28
+ export interface ISyncEventMessage {
29
+ event: 'sync';
30
+ status: OperationStatus;
31
+ }
32
+ /**
33
+ * A message sent by the host to tell the watch loop to cancel the current run.
34
+ *
35
+ * @beta
36
+ */
37
+ export interface ICancelCommandMessage {
38
+ command: 'cancel';
39
+ }
40
+ /**
41
+ * A message sent by the host to tell the watch loop to shutdown gracefully.
42
+ *
43
+ * @beta
44
+ */
45
+ export interface IExitCommandMessage {
46
+ command: 'exit';
47
+ }
48
+ /**
49
+ * A message sent by the host to tell the watch loop to perform a single run.
50
+ *
51
+ * @beta
52
+ */
53
+ export interface IRunCommandMessage {
54
+ command: 'run';
55
+ }
56
+ /**
57
+ * A message sent by the host to ask for to resync status information.
58
+ *
59
+ * @beta
60
+ */
61
+ export interface ISyncCommandMessage {
62
+ command: 'sync';
63
+ }
64
+ /**
65
+ * The set of known messages from the host to the watch loop.
66
+ * @beta
67
+ */
68
+ export type CommandMessageFromHost = ICancelCommandMessage | IExitCommandMessage | IRunCommandMessage | ISyncCommandMessage;
69
+ /**
70
+ * The set of known messages from the watch loop to the host.
71
+ * @beta
72
+ */
73
+ export type EventMessageFromClient = IRequestRunEventMessage | IAfterExecuteEventMessage | ISyncEventMessage;
74
+ /**
75
+ * The interface contract for IPC send/receive, to support alternate channels and unit tests.
76
+ *
77
+ * @beta
78
+ */
79
+ export type IPCHost = Pick<typeof process, 'on' | 'send'>;
80
+ //# sourceMappingURL=protocol.types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"protocol.types.d.ts","sourceRoot":"","sources":["../src/protocol.types.ts"],"names":[],"mappings":";;AAGA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAEzD;;;;GAIG;AACH,MAAM,WAAW,uBAAuB;IACtC,KAAK,EAAE,YAAY,CAAC;IACpB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED;;;;GAIG;AACH,MAAM,WAAW,yBAAyB;IACxC,KAAK,EAAE,eAAe,CAAC;IACvB,MAAM,EAAE,eAAe,CAAC;CACzB;AAED;;;;;GAKG;AACH,MAAM,WAAW,iBAAiB;IAChC,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,eAAe,CAAC;CACzB;AAED;;;;GAIG;AACH,MAAM,WAAW,qBAAqB;IACpC,OAAO,EAAE,QAAQ,CAAC;CACnB;AAED;;;;GAIG;AACH,MAAM,WAAW,mBAAmB;IAClC,OAAO,EAAE,MAAM,CAAC;CACjB;AAED;;;;GAIG;AACH,MAAM,WAAW,kBAAkB;IACjC,OAAO,EAAE,KAAK,CAAC;CAChB;AAED;;;;GAIG;AACH,MAAM,WAAW,mBAAmB;IAClC,OAAO,EAAE,MAAM,CAAC;CACjB;AAED;;;GAGG;AACH,MAAM,MAAM,sBAAsB,GAC9B,qBAAqB,GACrB,mBAAmB,GACnB,kBAAkB,GAClB,mBAAmB,CAAC;AAExB;;;GAGG;AACH,MAAM,MAAM,sBAAsB,GAAG,uBAAuB,GAAG,yBAAyB,GAAG,iBAAiB,CAAC;AAE7G;;;;GAIG;AACH,MAAM,MAAM,OAAO,GAAG,IAAI,CAAC,OAAO,OAAO,EAAE,IAAI,GAAG,MAAM,CAAC,CAAC"}
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ // Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
3
+ // See LICENSE in the project root for license information.
4
+ Object.defineProperty(exports, "__esModule", { value: true });
5
+ //# sourceMappingURL=protocol.types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"protocol.types.js","sourceRoot":"","sources":["../src/protocol.types.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.\n// See LICENSE in the project root for license information.\n\nimport type { OperationStatus } from './OperationStatus';\n\n/**\n * A message sent to the host to ask it to run this task.\n *\n * @beta\n */\nexport interface IRequestRunEventMessage {\n event: 'requestRun';\n requestor?: string;\n}\n\n/**\n * A message sent to the host upon completion of a run of this task.\n *\n * @beta\n */\nexport interface IAfterExecuteEventMessage {\n event: 'after-execute';\n status: OperationStatus;\n}\n\n/**\n * A message sent to the host upon connection of the channel, to indicate\n * to the host that this task supports the protocol and to provide baseline status information.\n *\n * @beta\n */\nexport interface ISyncEventMessage {\n event: 'sync';\n status: OperationStatus;\n}\n\n/**\n * A message sent by the host to tell the watch loop to cancel the current run.\n *\n * @beta\n */\nexport interface ICancelCommandMessage {\n command: 'cancel';\n}\n\n/**\n * A message sent by the host to tell the watch loop to shutdown gracefully.\n *\n * @beta\n */\nexport interface IExitCommandMessage {\n command: 'exit';\n}\n\n/**\n * A message sent by the host to tell the watch loop to perform a single run.\n *\n * @beta\n */\nexport interface IRunCommandMessage {\n command: 'run';\n}\n\n/**\n * A message sent by the host to ask for to resync status information.\n *\n * @beta\n */\nexport interface ISyncCommandMessage {\n command: 'sync';\n}\n\n/**\n * The set of known messages from the host to the watch loop.\n * @beta\n */\nexport type CommandMessageFromHost =\n | ICancelCommandMessage\n | IExitCommandMessage\n | IRunCommandMessage\n | ISyncCommandMessage;\n\n/**\n * The set of known messages from the watch loop to the host.\n * @beta\n */\nexport type EventMessageFromClient = IRequestRunEventMessage | IAfterExecuteEventMessage | ISyncEventMessage;\n\n/**\n * The interface contract for IPC send/receive, to support alternate channels and unit tests.\n *\n * @beta\n */\nexport type IPCHost = Pick<typeof process, 'on' | 'send'>;\n"]}
package/package.json ADDED
@@ -0,0 +1,36 @@
1
+ {
2
+ "name": "@rushstack/operation-graph",
3
+ "version": "0.1.0",
4
+ "description": "Library for managing and executing operations in a directed acyclic graph.",
5
+ "main": "lib/index.js",
6
+ "typings": "dist/operation-graph.d.ts",
7
+ "license": "MIT",
8
+ "repository": {
9
+ "url": "https://github.com/microsoft/rushstack.git",
10
+ "type": "git",
11
+ "directory": "libraries/operation-graph"
12
+ },
13
+ "dependencies": {
14
+ "@rushstack/node-core-library": "3.60.0"
15
+ },
16
+ "devDependencies": {
17
+ "@rushstack/heft": "0.59.0",
18
+ "@rushstack/heft-node-rig": "2.2.23",
19
+ "@types/heft-jest": "1.0.1",
20
+ "@types/node": "18.17.15",
21
+ "@rushstack/eslint-config": "3.3.4"
22
+ },
23
+ "peerDependencies": {
24
+ "@types/node": "*"
25
+ },
26
+ "peerDependenciesMeta": {
27
+ "@types/node": {
28
+ "optional": true
29
+ }
30
+ },
31
+ "scripts": {
32
+ "build": "heft build --clean",
33
+ "_phase:build": "heft run --only build -- --clean",
34
+ "_phase:test": "heft run --only test -- --clean"
35
+ }
36
+ }