@overkill-dev/run 0.0.44 → 0.0.46

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 (55) hide show
  1. package/package.json +9 -2
  2. package/packages/run/resource-lifecycle.entry-point.d.ts +5 -0
  3. package/packages/run/resource-lifecycle.entry-point.d.ts.map +1 -0
  4. package/packages/run/resource-lifecycle.entry-point.js +4 -0
  5. package/packages/run/resource-lifecycle.entry-point.js.map +1 -0
  6. package/readme.md +4 -0
  7. package/resources/resource-graph.d.ts +23 -0
  8. package/resources/resource-graph.d.ts.map +1 -0
  9. package/resources/resource-graph.js +132 -0
  10. package/resources/resource-graph.js.map +1 -0
  11. package/resources/resource-lifecycle-error.d.ts +19 -0
  12. package/resources/resource-lifecycle-error.d.ts.map +1 -0
  13. package/resources/resource-lifecycle-error.js +16 -0
  14. package/resources/resource-lifecycle-error.js.map +1 -0
  15. package/resources/resource-session.d.ts +28 -0
  16. package/resources/resource-session.d.ts.map +1 -0
  17. package/resources/resources.d.ts +175 -0
  18. package/resources/resources.d.ts.map +1 -0
  19. package/resources/resources.js +9 -0
  20. package/resources/resources.js.map +1 -0
  21. package/run/resource-lifecycle-composition.d.ts +37 -0
  22. package/run/resource-lifecycle-composition.d.ts.map +1 -0
  23. package/run/resource-lifecycle-composition.js +94 -0
  24. package/run/resource-lifecycle-composition.js.map +1 -0
  25. package/run/resource-lifecycle-error.d.ts +4 -0
  26. package/run/resource-lifecycle-error.d.ts.map +1 -0
  27. package/run/resource-lifecycle-error.js +17 -0
  28. package/run/resource-lifecycle-error.js.map +1 -0
  29. package/run/resource-lifecycle-managed-session.js +44 -0
  30. package/run/resource-lifecycle-managed-session.js.map +1 -0
  31. package/run/resource-lifecycle-state.d.ts +15 -0
  32. package/run/resource-lifecycle-state.d.ts.map +1 -0
  33. package/run/resource-lifecycle-state.js +16 -0
  34. package/run/resource-lifecycle-state.js.map +1 -0
  35. package/run/resource-lifecycle.js +320 -0
  36. package/run/resource-lifecycle.js.map +1 -0
  37. package/run/run-support.js +37 -0
  38. package/run/run-support.js.map +1 -1
  39. package/run/run-types.d.ts +9 -0
  40. package/run/run-types.d.ts.map +1 -1
  41. package/run/run-types.js +7 -0
  42. package/run/run-types.js.map +1 -1
  43. package/run/run.js +2 -2
  44. package/run/run.js.map +1 -1
  45. package/run/supervised-child.js +2 -1
  46. package/run/supervised-child.js.map +1 -1
  47. package/run/work-unit-planning.js +19 -3
  48. package/run/work-unit-planning.js.map +1 -1
  49. package/run/work-unit-resource-constraints.js +148 -0
  50. package/run/work-unit-resource-constraints.js.map +1 -0
  51. package/run/worker-pool-lanes.js +112 -1
  52. package/run/worker-pool-lanes.js.map +1 -1
  53. package/run/worker-pool-worker.js +4 -2
  54. package/run/worker-pool-worker.js.map +1 -1
  55. package/sbom.cdx.json +9 -9
package/package.json CHANGED
@@ -13,7 +13,7 @@
13
13
  "string-width": "8.2.2",
14
14
  "tinypool": "2.1.2",
15
15
  "yoctocolors": "2.2.0",
16
- "zod": "4.6.2"
16
+ "zod": "4.6.4"
17
17
  },
18
18
  "description": "Overkill run resolution and orchestration.",
19
19
  "engines": {
@@ -35,6 +35,10 @@
35
35
  "./filters": {
36
36
  "import": "./packages/run/filters.entry-point.js",
37
37
  "types": "./packages/run/filters.entry-point.d.ts"
38
+ },
39
+ "./resource-lifecycle": {
40
+ "import": "./packages/run/resource-lifecycle.entry-point.js",
41
+ "types": "./packages/run/resource-lifecycle.entry-point.d.ts"
38
42
  }
39
43
  },
40
44
  "homepage": "https://github.com/enormora/overkill#readme",
@@ -73,6 +77,8 @@
73
77
  "./run/default-run-engine.js",
74
78
  "./run/node-process-capability-restrictions.js",
75
79
  "./run/node-run-dependencies.entry-point.js",
80
+ "./run/resource-lifecycle-state.js",
81
+ "./run/resource-lifecycle.js",
76
82
  "./run/run-config-schema.js",
77
83
  "./run/run-filter-grammar.js",
78
84
  "./run/run-host-process.js",
@@ -80,6 +86,7 @@
80
86
  "./run/run-if-main.js",
81
87
  "./run/run-orchestrator.entry-point.js",
82
88
  "./run/run-selection-filters.js",
89
+ "./run/run-types.js",
83
90
  "./run/supervised-child-process.js",
84
91
  "./run/supervised-child.entry-point.js",
85
92
  "./run/supervised-run-state.js",
@@ -88,5 +95,5 @@
88
95
  "./run/worker-pool-runtime.js"
89
96
  ],
90
97
  "type": "module",
91
- "version": "0.0.44"
98
+ "version": "0.0.46"
92
99
  }
@@ -0,0 +1,5 @@
1
+ export { activeManagedLifecycle } from '../../run/resource-lifecycle-state.ts';
2
+ export { combinedResourceEntries, composedResourceSession, directResourceEntries, resourceMapFromEntries, resourceContextForStep, runtimeContextForStep, stepRuntimeGraphs } from '../../run/resource-lifecycle-composition.ts';
3
+ export { resourceWrapperErrorFromUnknown, resourceWrapperLifecycleError } from '../../run/resource-lifecycle-error.ts';
4
+ export type { ComposedResourceSession, LifecycleMessages, ResourceWrapperStep } from '../../run/resource-lifecycle-composition.ts';
5
+ //# sourceMappingURL=resource-lifecycle.entry-point.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"resource-lifecycle.entry-point.d.ts","sourceRoot":"","sources":["../../../../../source/packages/run/resource-lifecycle.entry-point.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,sBAAsB,EACzB,MAAM,uCAAuC,CAAC;AAC/C,OAAO,EACH,uBAAuB,EACvB,uBAAuB,EACvB,qBAAqB,EACrB,sBAAsB,EACtB,sBAAsB,EACtB,qBAAqB,EACrB,iBAAiB,EACpB,MAAM,6CAA6C,CAAC;AACrD,OAAO,EACH,+BAA+B,EAC/B,6BAA6B,EAChC,MAAM,uCAAuC,CAAC;AAC/C,YAAY,EACR,uBAAuB,EACvB,iBAAiB,EACjB,mBAAmB,EACtB,MAAM,6CAA6C,CAAC"}
@@ -0,0 +1,4 @@
1
+ export { activeManagedLifecycle } from "../../run/resource-lifecycle-state.js";
2
+ export { combinedResourceEntries, composedResourceSession, directResourceEntries, resourceMapFromEntries, resourceContextForStep, runtimeContextForStep, stepRuntimeGraphs } from "../../run/resource-lifecycle-composition.js";
3
+ export { resourceWrapperErrorFromUnknown, resourceWrapperLifecycleError } from "../../run/resource-lifecycle-error.js";
4
+ //# sourceMappingURL=resource-lifecycle.entry-point.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"resource-lifecycle.entry-point.js","sourceRoot":"","sources":["../../../../../source/packages/run/resource-lifecycle.entry-point.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,sBAAsB,EACzB,MAAM,uCAAuC,CAAC;AAC/C,OAAO,EACH,uBAAuB,EACvB,uBAAuB,EACvB,qBAAqB,EACrB,sBAAsB,EACtB,sBAAsB,EACtB,qBAAqB,EACrB,iBAAiB,EACpB,MAAM,6CAA6C,CAAC;AACrD,OAAO,EACH,+BAA+B,EAC/B,6BAA6B,EAChC,MAAM,uCAAuC,CAAC"}
package/readme.md CHANGED
@@ -70,6 +70,10 @@ Programmatic selection helpers are exposed through `@overkill-dev/run/filters`:
70
70
  - `tag(value)`
71
71
  - `title(value)`
72
72
 
73
+ Resource wrapper lifecycle coordination is exposed through
74
+ `@overkill-dev/run/resource-lifecycle` for packages that compose
75
+ runner-managed resource scopes with test-body authoring wrappers.
76
+
73
77
  The current runner accepts explicit file paths through `RunRequest.paths` and
74
78
  profile file discovery through `profiles.<name>.files`. Profile files may use
75
79
  top-level `include` and `exclude`, or mutually exclusive named `sets` whose
@@ -0,0 +1,23 @@
1
+ import { type AnyResourceDefinition, type Awaitable, type ResourceCreationContext, type ResourceDependencies, type ResourceDisposalContext } from './resources.ts';
2
+ export type ResourceEntry = readonly [string, AnyResourceDefinition];
3
+ export type ResourceNode = {
4
+ readonly dependencies: readonly ResourceNode[];
5
+ readonly descriptor: AnyResourceDefinition;
6
+ };
7
+ export type ResourceGraph = {
8
+ readonly order: readonly ResourceNode[];
9
+ readonly topLevelEntries: readonly ResourceEntry[];
10
+ };
11
+ type DependencyDisposalContext = ResourceDisposalContext<ResourceDependencies>;
12
+ export type ResourceDisposeCallback = (handle: unknown, context: DependencyDisposalContext) => Awaitable<void>;
13
+ export type CallableResourceDefinition = AnyResourceDefinition & {
14
+ readonly acquire: (context: ResourceCreationContext<ResourceDependencies>) => Awaitable<unknown>;
15
+ readonly dispose: ResourceDisposeCallback | null;
16
+ };
17
+ export declare function resourceEntries(resources: ResourceDependencies): readonly ResourceEntry[];
18
+ export declare function callableResourceDefinition(resource: AnyResourceDefinition): CallableResourceDefinition;
19
+ export declare function createResourceGraph(resources: ResourceDependencies): ResourceGraph;
20
+ export declare function assertPerCaseResourceGraph(resources: ResourceDependencies): void;
21
+ export declare function assertResourceDependencyScopes(resources: ResourceDependencies): void;
22
+ export {};
23
+ //# sourceMappingURL=resource-graph.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"resource-graph.d.ts","sourceRoot":"","sources":["../../../../source/resources/resource-graph.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,KAAK,qBAAqB,EAC1B,KAAK,SAAS,EAEd,KAAK,uBAAuB,EAC5B,KAAK,oBAAoB,EACzB,KAAK,uBAAuB,EAE/B,MAAM,gBAAgB,CAAC;AAaxB,MAAM,MAAM,aAAa,GAAG,SAAS,CAAC,MAAM,EAAE,qBAAqB,CAAC,CAAC;AACrE,MAAM,MAAM,YAAY,GAAG;IACvB,QAAQ,CAAC,YAAY,EAAE,SAAS,YAAY,EAAE,CAAC;IAC/C,QAAQ,CAAC,UAAU,EAAE,qBAAqB,CAAC;CAC9C,CAAC;AACF,MAAM,MAAM,aAAa,GAAG;IACxB,QAAQ,CAAC,KAAK,EAAE,SAAS,YAAY,EAAE,CAAC;IACxC,QAAQ,CAAC,eAAe,EAAE,SAAS,aAAa,EAAE,CAAC;CACtD,CAAC;AACF,KAAK,yBAAyB,GAAG,uBAAuB,CAAC,oBAAoB,CAAC,CAAC;AAC/E,MAAM,MAAM,uBAAuB,GAAG,CAAC,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,yBAAyB,KAAK,SAAS,CAAC,IAAI,CAAC,CAAC;AAC/G,MAAM,MAAM,0BAA0B,GAAG,qBAAqB,GAAG;IAC7D,QAAQ,CAAC,OAAO,EAAE,CAAC,OAAO,EAAE,uBAAuB,CAAC,oBAAoB,CAAC,KAAK,SAAS,CAAC,OAAO,CAAC,CAAC;IACjG,QAAQ,CAAC,OAAO,EAAE,uBAAuB,GAAG,IAAI,CAAC;CACpD,CAAC;AAQF,wBAAgB,eAAe,CAAC,SAAS,EAAE,oBAAoB,GAAG,SAAS,aAAa,EAAE,CAEzF;AA+CD,wBAAgB,0BAA0B,CAAC,QAAQ,EAAE,qBAAqB,GAAG,0BAA0B,CAQtG;AAiFD,wBAAgB,mBAAmB,CAAC,SAAS,EAAE,oBAAoB,GAAG,aAAa,CAElF;AAED,wBAAgB,0BAA0B,CAAC,SAAS,EAAE,oBAAoB,GAAG,IAAI,CAuBhF;AAED,wBAAgB,8BAA8B,CAAC,SAAS,EAAE,oBAAoB,GAAG,IAAI,CAwBpF"}
@@ -0,0 +1,132 @@
1
+ import { isDefinedResource } from "./resources.js";
2
+ import { resourceLifecycleError } from "./resource-lifecycle-error.js";
3
+ const perRunScopeRank = 0;
4
+ const perFileScopeRank = 1;
5
+ const perSuiteScopeRank = 2;
6
+ const sharedPerWorkerScopeRank = 3;
7
+ const perCaseScopeRank = 4;
8
+ export function resourceEntries(resources) {
9
+ return Object.entries(resources);
10
+ }
11
+
12
+ function scopeRank(scope) {
13
+ if (scope === 'per-run') {
14
+ return perRunScopeRank;
15
+ }
16
+ if (scope === 'per-file') {
17
+ return perFileScopeRank;
18
+ }
19
+ if (scope === 'per-suite') {
20
+ return perSuiteScopeRank;
21
+ }
22
+ if (scope === 'shared-per-worker') {
23
+ return sharedPerWorkerScopeRank;
24
+ }
25
+ return perCaseScopeRank;
26
+ }
27
+ function dependencyScopeAllowed(resource, dependency) {
28
+ const resourceScope = resource.scope;
29
+ const dependencyScope = dependency.scope;
30
+ if (dependencyScope === 'shared-per-worker') {
31
+ return resource.scope === 'shared-per-worker' || resource.scope === 'per-case';
32
+ }
33
+ if (resourceScope === 'shared-per-worker') {
34
+ return dependency.scope === 'per-run' || dependency.scope === 'shared-per-worker';
35
+ }
36
+ return scopeRank(dependencyScope) <= scopeRank(resourceScope);
37
+ }
38
+ function hasCallableResourceCallbacks(resource) {
39
+ return isDefinedResource(resource) && typeof resource.acquire === 'function';
40
+ }
41
+ export function callableResourceDefinition(resource) {
42
+ if (hasCallableResourceCallbacks(resource)) {
43
+ return resource;
44
+ }
45
+ throw resourceLifecycleError('Resource descriptor is invalid.', [
46
+ { cause: resource, phase: 'graph', resourceName: 'resource' }
47
+ ], resource);
48
+ }
49
+ function assertUniqueResourceName(descriptorsByName, resource) {
50
+ const descriptorForName = descriptorsByName.get(resource.name);
51
+ if (descriptorForName !== undefined && descriptorForName !== resource) {
52
+ throw resourceLifecycleError(`Resource name "${resource.name}" is used by multiple descriptors.`, [
53
+ { cause: resource, phase: 'graph', resourceName: resource.name }
54
+ ], resource);
55
+ }
56
+ }
57
+ function assertResourceAcyclic(traversal, resource, path) {
58
+ if (traversal.has(resource)) {
59
+ throw resourceLifecycleError(`Resource dependency cycle detected: ${path.join(' -> ')}.`, [
60
+ { cause: resource, phase: 'graph', resourceName: resource.name }
61
+ ], resource);
62
+ }
63
+ }
64
+ function createResourceGraphBuilder() {
65
+ const descriptorsByName = new Map();
66
+ const nodesByDescriptor = new Map();
67
+ const order = [];
68
+ const traversal = new Set();
69
+ const builder = {
70
+ assertAcyclic(resource, path) {
71
+ assertResourceAcyclic(traversal, resource, path);
72
+ },
73
+ assertUniqueName(resource) {
74
+ assertUniqueResourceName(descriptorsByName, resource);
75
+ descriptorsByName.set(resource.name, resource);
76
+ },
77
+ build(resources) {
78
+ const topLevelEntries = resourceEntries(resources);
79
+ for (const [, resource] of topLevelEntries) {
80
+ builder.visit(resource, [resource.name]);
81
+ }
82
+ return { order, topLevelEntries };
83
+ },
84
+ record(resource, path) {
85
+ traversal.add(resource);
86
+ const dependencies = resourceEntries(resource.dependencies).map(function visitDependency([, dependency]) {
87
+ return builder.visit(dependency, [...path, dependency.name]);
88
+ });
89
+ const node = { dependencies, descriptor: resource };
90
+ traversal.delete(resource);
91
+ nodesByDescriptor.set(resource, node);
92
+ order.push(node);
93
+ return node;
94
+ },
95
+ visit(resource, path) {
96
+ const callableResource = callableResourceDefinition(resource);
97
+ const existingNode = nodesByDescriptor.get(callableResource);
98
+ builder.assertUniqueName(callableResource);
99
+ builder.assertAcyclic(callableResource, path);
100
+ if (existingNode !== undefined) {
101
+ return existingNode;
102
+ }
103
+ return builder.record(callableResource, path);
104
+ }
105
+ };
106
+ return builder;
107
+ }
108
+ export function createResourceGraph(resources) {
109
+ return createResourceGraphBuilder().build(resources);
110
+ }
111
+
112
+ export function assertResourceDependencyScopes(resources) {
113
+ const graph = createResourceGraph(resources);
114
+ for (const node of graph.order) {
115
+ for (const dependency of node.dependencies) {
116
+ if (!dependencyScopeAllowed(node.descriptor, dependency.descriptor)) {
117
+ throw resourceLifecycleError([
118
+ `Resource "${node.descriptor.name}" uses ${node.descriptor.scope} scope and cannot depend on`,
119
+ `resource "${dependency.descriptor.name}" with ${dependency.descriptor.scope} scope.`
120
+ ]
121
+ .join(' '), [
122
+ {
123
+ cause: dependency.descriptor,
124
+ phase: 'graph',
125
+ resourceName: node.descriptor.name
126
+ }
127
+ ], dependency.descriptor);
128
+ }
129
+ }
130
+ }
131
+ }
132
+ //# sourceMappingURL=resource-graph.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"resource-graph.js","sourceRoot":"","sources":["../../../../source/resources/resource-graph.ts"],"names":[],"mappings":"AAAA,OAAO,EAGH,iBAAiB,EAKpB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,sBAAsB,EAAE,MAAM,+BAA+B,CAAC;AA4BvE,MAAM,eAAe,GAAG,CAAC,CAAC;AAC1B,MAAM,gBAAgB,GAAG,CAAC,CAAC;AAC3B,MAAM,iBAAiB,GAAG,CAAC,CAAC;AAC5B,MAA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BACI,KAAK,EAAE,UAAU,CAAC,UAAU;wBAC5B,KAAK,EAAE,OAAO;wBACd,YAAY,EAAE,IAAI,CAAC,UAAU,CAAC,IAAI;qBACrC;iBACJ,EACD,UAAU,CAAC,UAAU,CACxB,CAAC;YACN,CAAC;QACL,CAAC;IACL,CAAC;AACL,CAAC"}
@@ -0,0 +1,19 @@
1
+ export type ResourceLifecyclePhase = 'acquire' | 'dispose' | 'graph';
2
+ export type ResourceLifecycleFailure = {
3
+ readonly cause: unknown;
4
+ readonly phase: ResourceLifecyclePhase;
5
+ readonly resourceName: string;
6
+ };
7
+ type ResourceLifecycleErrorOptions = {
8
+ readonly cause: unknown;
9
+ readonly failures: readonly ResourceLifecycleFailure[];
10
+ };
11
+ export declare class ResourceLifecycleError extends Error {
12
+ private readonly lifecycleFailures;
13
+ constructor(message: string, options: ResourceLifecycleErrorOptions);
14
+ failures(): readonly ResourceLifecycleFailure[];
15
+ }
16
+ export declare function resourceLifecycleError(message: string, failures: readonly ResourceLifecycleFailure[], cause: unknown): ResourceLifecycleError;
17
+ export declare function lifecycleFailures(results: readonly PromiseSettledResult<unknown>[], fallbackResourceName: string): readonly ResourceLifecycleFailure[];
18
+ export {};
19
+ //# sourceMappingURL=resource-lifecycle-error.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"resource-lifecycle-error.d.ts","sourceRoot":"","sources":["../../../../source/resources/resource-lifecycle-error.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,sBAAsB,GAAG,SAAS,GAAG,SAAS,GAAG,OAAO,CAAC;AAErE,MAAM,MAAM,wBAAwB,GAAG;IACnC,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAC;IACxB,QAAQ,CAAC,KAAK,EAAE,sBAAsB,CAAC;IACvC,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;CACjC,CAAC;AAEF,KAAK,6BAA6B,GAAG;IACjC,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAC;IACxB,QAAQ,CAAC,QAAQ,EAAE,SAAS,wBAAwB,EAAE,CAAC;CAC1D,CAAC;AAEF,qBAAa,sBAAuB,SAAQ,KAAK;IAC7C,OAAO,CAAC,QAAQ,CAAC,iBAAiB,CAAsC;gBAGpE,OAAO,EAAE,MAAM,EACf,OAAO,EAAE,6BAA6B;IAOnC,QAAQ,IAAI,SAAS,wBAAwB,EAAE;CAGzD;AAED,wBAAgB,sBAAsB,CAClC,OAAO,EAAE,MAAM,EACf,QAAQ,EAAE,SAAS,wBAAwB,EAAE,EAC7C,KAAK,EAAE,OAAO,GACf,sBAAsB,CAExB;AAUD,wBAAgB,iBAAiB,CAC7B,OAAO,EAAE,SAAS,oBAAoB,CAAC,OAAO,CAAC,EAAE,EACjD,oBAAoB,EAAE,MAAM,GAC7B,SAAS,wBAAwB,EAAE,CAYrC"}
@@ -0,0 +1,16 @@
1
+ export class ResourceLifecycleError extends Error {
2
+ lifecycleFailures;
3
+ constructor(message, options) {
4
+ super(message, options);
5
+ this.name = 'ResourceLifecycleError';
6
+ this.lifecycleFailures = options.failures;
7
+ }
8
+ failures() {
9
+ return this.lifecycleFailures;
10
+ }
11
+ }
12
+ export function resourceLifecycleError(message, failures, cause) {
13
+ return new ResourceLifecycleError(message, { cause, failures });
14
+ }
15
+
16
+ //# sourceMappingURL=resource-lifecycle-error.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"resource-lifecycle-error.js","sourceRoot":"","sources":["../../../../source/resources/resource-lifecycle-error.ts"],"names":[],"mappings":"AAaA,MAAM,OAAO,sBAAuB,SAAQ,KAAK;IAC5B,iBAAiB,CAAsC;IAExE,YACI,OAAe,EACf,OAAsC;QAEtC,KAAK,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;QACxB,IAAI,CAAC,IAAI,GAAG,wBAAwB,CAAC;QACrC,IAAI,CAAC,iBAAiB,GAAG,OAAO,CAAC,QAAQ,CAAC;IAC9C,CAAC;IAEM,QAAQ;QACX,OAAO,IAAI,CAAC,iBAAiB,CAAC;IAClC,CAAC;CACJ;AAED,MAAM,UAAU,sBAAsB,CAClC,OAAe,EACf,QAA6C,EAC7C,KAAc;IAEd,OAAO,IAAI,sBAAsB,CAAC,OAAO,EAAE,EAAE,KAAK,EAAE,QAAQ,EAAE,CAAC,CAAC;AACpE,CAAC"}
@@ -0,0 +1,28 @@
1
+ import type { AnyResourceDefinition, ResourceContext, ResourceDependencies } from './resources.ts';
2
+ import { type ResourceNode } from './resource-graph.ts';
3
+ import { type ResourceLifecycleFailure } from './resource-lifecycle-error.ts';
4
+ type ResourceAcquisitionContext = {
5
+ readonly acquisitionFailureMessage: string;
6
+ readonly fallbackResourceName: string;
7
+ };
8
+ export type StartResourcesRequest<Resources extends ResourceDependencies> = {
9
+ readonly resources: Resources;
10
+ readonly signal: AbortSignal;
11
+ };
12
+ export type ResourceSessionDisposalContext = {
13
+ readonly signal: AbortSignal;
14
+ };
15
+ export type ResourceSession<Resources extends ResourceDependencies> = AsyncDisposable & {
16
+ readonly context: ResourceContext<Resources>;
17
+ readonly disposeOnce: (context: ResourceSessionDisposalContext) => Promise<void>;
18
+ };
19
+ export declare function disposeResources(order: readonly ResourceNode[], handles: ReadonlyMap<AnyResourceDefinition, unknown>, signal: AbortSignal): Promise<readonly ResourceLifecycleFailure[]>;
20
+ export declare function runtimeAsyncDisposeSymbol(): symbol;
21
+ export declare function acquireResourceGraph<Resources extends ResourceDependencies>(request: StartResourcesRequest<Resources>, context: ResourceAcquisitionContext): Promise<{
22
+ readonly context: ResourceContext<Resources>;
23
+ readonly handles: ReadonlyMap<AnyResourceDefinition, unknown>;
24
+ readonly order: readonly ResourceNode[];
25
+ }>;
26
+ export declare function startResources<Resources extends ResourceDependencies>(request: StartResourcesRequest<Resources>): Promise<ResourceSession<Resources>>;
27
+ export {};
28
+ //# sourceMappingURL=resource-session.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"resource-session.d.ts","sourceRoot":"","sources":["../../../../source/resources/resource-session.ts"],"names":[],"mappings":"AAAA,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AAS,CAAC,CAAC;IAC7C,QAAQ,CAAC,OAAO,EAAE,WAAW,CAAC,qBAAqB,EAAE,OAAO,CAAC,CAAC;IAC9D,QAAQ,CAAC,KAAK,EAAE,SAAS,YAAY,EAAE,CAAC;CAC3C,CAAC,CASD;AAED,wBAAsB,cAAc,CAAC,SAAS,SAAS,oBAAoB,EACvE,OAAO,EAAE,qBAAqB,CAAC,SAAS,CAAC,GAC1C,OAAO,CAAC,eAAe,CAAC,SAAS,CAAC,CAAC,CA4BrC"}
@@ -0,0 +1,175 @@
1
+ declare const resourceDefinitionBrand: unique symbol;
2
+ declare const runtimeDefinitionBrand: unique symbol;
3
+ export type Awaitable<Value> = Promise<Value> | Value;
4
+ type ValueOf<Values> = Values[keyof Values];
5
+ type ExclusiveResource = {
6
+ readonly kind: 'exclusive-resource';
7
+ readonly name: string;
8
+ };
9
+ type SerialExecution = {
10
+ readonly kind: 'serial';
11
+ };
12
+ type SingleWorkerExecution = {
13
+ readonly kind: 'single-worker';
14
+ };
15
+ type StartupBudget = {
16
+ readonly kind: 'startup-budget-milliseconds';
17
+ readonly minimumMilliseconds: number;
18
+ };
19
+ type CapacityWeight = {
20
+ readonly kind: 'capacity-weight';
21
+ readonly weight: number;
22
+ };
23
+ type AffinityKey = {
24
+ readonly key: string;
25
+ readonly kind: 'affinity-key';
26
+ };
27
+ type FaultDomain = {
28
+ readonly key: string;
29
+ readonly kind: 'fault-domain';
30
+ };
31
+ export type AnyResourceDefinition = {
32
+ readonly acquire: (context: never) => Awaitable<unknown>;
33
+ readonly dependencies: ResourceDependencies;
34
+ readonly deserializeHandle?: (payload: never, context: never) => unknown;
35
+ readonly dispose: ((handle: never, context: never) => Awaitable<void>) | null;
36
+ readonly name: string;
37
+ readonly requirements: readonly ExecutionRequirement[];
38
+ readonly scope: ResourceScope;
39
+ readonly serializeHandle?: (handle: never, context: never) => ResourceProjectionPayload;
40
+ readonly [resourceDefinitionBrand]: true;
41
+ };
42
+ export type RuntimeResourceMap = Readonly<Record<string, AnyResourceDefinition>>;
43
+ export type EmptyResourceDependencies = Readonly<Record<PropertyKey, never>>;
44
+ export type RuntimeDimensions = Readonly<Record<string, string>>;
45
+ export type RuntimeId<Name extends string = string, Dimensions extends RuntimeDimensions = RuntimeDimensions> = {
46
+ readonly name: Name;
47
+ readonly dimensions: Dimensions;
48
+ };
49
+ type PlacementRequirement = AffinityKey | CapacityWeight | ExclusiveResource | FaultDomain;
50
+ type SchedulingRequirement = SerialExecution | SingleWorkerExecution | StartupBudget;
51
+ export type ExecutionRequirement = PlacementRequirement | SchedulingRequirement;
52
+ export type ResourceScope = 'per-case' | 'per-file' | 'per-run' | 'per-suite' | 'shared-per-worker';
53
+ export type ResourceDependencies = Readonly<Record<string, AnyResourceDefinition>>;
54
+ type ResourceProjectionObject = {
55
+ readonly [key: string]: ResourceProjectionPayload;
56
+ };
57
+ type ResourceProjectionScalar = boolean | number | string | null;
58
+ type ResourceProjectionCollection = ResourceProjectionObject | readonly ResourceProjectionPayload[];
59
+ export type ResourceProjectionPayload = ResourceProjectionCollection | ResourceProjectionScalar;
60
+ export type ResourceProjectionContext<Dependencies extends ResourceDependencies = EmptyResourceDependencies> = {
61
+ readonly dependencies: ResourceContext<Dependencies>;
62
+ };
63
+ export type ResourceHandle<Resource extends AnyResourceDefinition> = Resource extends {
64
+ readonly deserializeHandle?: ((payload: never, context: never) => infer ConsumerHandle) | undefined;
65
+ } ? ConsumerHandle : Awaited<ReturnType<Resource['acquire']>>;
66
+ export type ResourceContext<Resources extends ResourceDependencies> = {
67
+ readonly [Key in keyof Resources]: ResourceHandle<Resources[Key]>;
68
+ };
69
+ export type ResourceCreationContext<Dependencies extends ResourceDependencies = EmptyResourceDependencies> = {
70
+ readonly dependencies: ResourceContext<Dependencies>;
71
+ readonly signal: AbortSignal;
72
+ };
73
+ export type ResourceDisposalContext<Dependencies extends ResourceDependencies = EmptyResourceDependencies> = {
74
+ readonly dependencies: ResourceContext<Dependencies>;
75
+ readonly signal: AbortSignal;
76
+ };
77
+ type ResourceDefinitionBaseInput<Name extends string, Handle, Scope extends ResourceScope, Dependencies extends ResourceDependencies = EmptyResourceDependencies> = {
78
+ readonly acquire: (context: ResourceCreationContext<Dependencies>) => Awaitable<Handle>;
79
+ readonly dependencies?: Dependencies;
80
+ readonly dispose: ((handle: Handle, context: ResourceDisposalContext<Dependencies>) => Awaitable<void>) | null;
81
+ readonly name: Name;
82
+ readonly requirements: readonly ExecutionRequirement[];
83
+ readonly scope: Scope;
84
+ };
85
+ type LocalOnlyResourceDefinitionInput<Name extends string, Handle, Scope extends ResourceScope, Dependencies extends ResourceDependencies = EmptyResourceDependencies> = ResourceDefinitionBaseInput<Name, Handle, Scope, Dependencies> & {
86
+ readonly deserializeHandle?: never;
87
+ readonly serializeHandle?: never;
88
+ };
89
+ type ProjectedResourceDefinitionInput<Name extends string, OwnerHandle, Projection extends ResourceProjectionPayload, ConsumerHandle, Scope extends 'per-file' | 'per-run' | 'per-suite', Dependencies extends ResourceDependencies = EmptyResourceDependencies> = ResourceDefinitionBaseInput<Name, OwnerHandle, Scope, Dependencies> & {
90
+ readonly deserializeHandle: (payload: Projection, context: ResourceProjectionContext<Dependencies>) => ConsumerHandle;
91
+ readonly serializeHandle: (handle: OwnerHandle, context: ResourceProjectionContext<Dependencies>) => Projection;
92
+ };
93
+ export type ResourceDefinitionInput<Name extends string, Handle, Dependencies extends ResourceDependencies = EmptyResourceDependencies, Projection extends ResourceProjectionPayload = ResourceProjectionPayload, ConsumerHandle = Handle> = ValueOf<ResourceDefinitionInputOptions<Name, Handle, Dependencies, Projection, ConsumerHandle>>;
94
+ type ResourceDefinitionInputOptions<Name extends string, Handle, Dependencies extends ResourceDependencies, Projection extends ResourceProjectionPayload, ConsumerHandle> = {
95
+ readonly local: LocalResourceDefinitionInput<Name, Handle, Dependencies>;
96
+ readonly projected: ProjectedResourceInput<Name, Handle, Projection, ConsumerHandle, Dependencies>;
97
+ };
98
+ type LocalResourceDefinitionInput<Name extends string, Handle, Dependencies extends ResourceDependencies> = LocalCaseResourceInput<Name, Handle, Dependencies> | LocalFileResourceInput<Name, Handle, Dependencies>;
99
+ type LocalCaseResourceInput<Name extends string, Handle, Dependencies extends ResourceDependencies> = LocalOnlyResourceDefinitionInput<Name, Handle, 'per-case' | 'shared-per-worker', Dependencies>;
100
+ type LocalFileResourceInput<Name extends string, Handle, Dependencies extends ResourceDependencies> = LocalOnlyResourceDefinitionInput<Name, Handle, 'per-file' | 'per-suite', Dependencies>;
101
+ type ProjectedResourceInput<Name extends string, Handle, Projection extends ResourceProjectionPayload, ConsumerHandle, Dependencies extends ResourceDependencies> = ValueOf<ProjectedResourceInputOptions<Name, Handle, Projection, ConsumerHandle, Dependencies>>;
102
+ type ProjectedResourceInputOptions<Name extends string, Handle, Projection extends ResourceProjectionPayload, ConsumerHandle, Dependencies extends ResourceDependencies> = {
103
+ readonly file: ProjectedFileResourceInput<Name, Handle, Projection, ConsumerHandle, Dependencies>;
104
+ readonly run: ProjectedRunResourceInput<Name, Handle, Projection, ConsumerHandle, Dependencies>;
105
+ };
106
+ type ProjectedFileResourceInput<Name extends string, Handle, Projection extends ResourceProjectionPayload, ConsumerHandle, Dependencies extends ResourceDependencies> = ProjectedResourceDefinitionInput<Name, Handle, Projection, ConsumerHandle, 'per-file' | 'per-suite', Dependencies>;
107
+ type ProjectedRunResourceInput<Name extends string, Handle, Projection extends ResourceProjectionPayload, ConsumerHandle, Dependencies extends ResourceDependencies> = ProjectedResourceDefinitionInput<Name, Handle, Projection, ConsumerHandle, 'per-run', Dependencies>;
108
+ export type ResourceDefinition<Name extends string = string, OwnerHandle = unknown, Dependencies extends ResourceDependencies = ResourceDependencies, ConsumerHandle = OwnerHandle> = {
109
+ readonly acquire: (context: ResourceCreationContext<Dependencies>) => Awaitable<OwnerHandle>;
110
+ readonly dependencies: Dependencies;
111
+ readonly deserializeHandle?: (payload: ResourceProjectionPayload, context: ResourceProjectionContext<Dependencies>) => ConsumerHandle;
112
+ readonly dispose: ((handle: OwnerHandle, context: ResourceDisposalContext<Dependencies>) => Awaitable<void>) | null;
113
+ readonly name: Name;
114
+ readonly requirements: readonly ExecutionRequirement[];
115
+ readonly scope: ResourceScope;
116
+ readonly serializeHandle?: (handle: OwnerHandle, context: ResourceProjectionContext<Dependencies>) => ResourceProjectionPayload;
117
+ readonly [resourceDefinitionBrand]: true;
118
+ };
119
+ export type RuntimeDefinitionInput<Name extends string, Dimensions extends RuntimeDimensions, Resources extends RuntimeResourceMap> = {
120
+ readonly dimensions: Dimensions;
121
+ readonly name: Name;
122
+ readonly requirements: readonly ExecutionRequirement[];
123
+ readonly resources: Resources;
124
+ };
125
+ export type RuntimeDefinition<Name extends string = string, Dimensions extends RuntimeDimensions = RuntimeDimensions, Resources extends RuntimeResourceMap = RuntimeResourceMap> = RuntimeDefinitionInput<Name, Dimensions, Resources> & {
126
+ readonly id: RuntimeId<Name, Dimensions>;
127
+ readonly [runtimeDefinitionBrand]: true;
128
+ };
129
+ export type RuntimeContext<Runtime extends RuntimeDefinition> = {
130
+ readonly [Key in keyof Runtime['resources']]: ResourceHandle<Runtime['resources'][Key]>;
131
+ };
132
+ export type RuntimeScopeContext<Runtime extends RuntimeDefinition> = Readonly<Record<Runtime['name'], RuntimeContext<Runtime>>>;
133
+ type EmptyRuntimeScopes = Pick<Readonly<Record<string, never>>, never>;
134
+ type RuntimeScopeKey<Runtime extends RuntimeDefinition> = Runtime['name'];
135
+ type RuntimeScopes<Context> = Context extends {
136
+ readonly runtimes: infer Runtimes extends Readonly<Record<string, unknown>>;
137
+ } ? Runtimes : EmptyRuntimeScopes;
138
+ type RuntimeScopeGuard<Context, Runtime extends RuntimeDefinition> = RuntimeScopeKey<Runtime> extends keyof RuntimeScopes<Context> ? never : unknown;
139
+ type RuntimeScopeBaseContext<Context> = {
140
+ readonly [Key in keyof Context as Key extends 'runtimes' ? never : Key]: Context[Key];
141
+ };
142
+ type ComposedRuntimeScopes<BaseContext, Runtime extends RuntimeDefinition> = {
143
+ readonly runtimes: RuntimeScopeContext<Runtime> & RuntimeScopes<BaseContext>;
144
+ };
145
+ export type RuntimeContextComposition<BaseContext, Runtime extends RuntimeDefinition> = Readonly<ComposedRuntimeScopes<BaseContext, Runtime> & RuntimeScopeBaseContext<BaseContext>>;
146
+ export type TemporaryDirectoryHandle = {
147
+ readonly path: string;
148
+ };
149
+ export type ResourcesModuleDependencies = {
150
+ readonly createTemporaryDirectory: (pathPrefix: string) => Awaitable<string>;
151
+ readonly removeDirectory: (path: string) => Awaitable<void>;
152
+ readonly temporaryDirectoryPathPrefix: string;
153
+ };
154
+ type CreateTemporaryDirectoryResource = <const Name extends string>(name: Name) => ResourceDefinition<Name, TemporaryDirectoryHandle, EmptyResourceDependencies>;
155
+ export type ResourcesModule = {
156
+ readonly composeRuntimeContext: typeof composeRuntimeContext;
157
+ readonly createTemporaryDirectoryResource: CreateTemporaryDirectoryResource;
158
+ readonly defineResource: typeof defineResource;
159
+ readonly defineRuntime: typeof defineRuntime;
160
+ };
161
+ export declare function defineResource<const Name extends string, Handle, Scope extends Exclude<ResourceScope, 'per-run'>>(definition: LocalOnlyResourceDefinitionInput<Name, Handle, Scope>): ResourceDefinition<Name, Handle, EmptyResourceDependencies>;
162
+ export declare function defineResource<const Name extends string, OwnerHandle, Projection extends ResourceProjectionPayload, ConsumerHandle, Scope extends 'per-file' | 'per-run' | 'per-suite'>(definition: ProjectedResourceDefinitionInput<Name, OwnerHandle, Projection, ConsumerHandle, Scope>): ResourceDefinition<Name, OwnerHandle, EmptyResourceDependencies, ConsumerHandle>;
163
+ export declare function defineResource<const Name extends string, Handle, Scope extends Exclude<ResourceScope, 'per-run'>, const Dependencies extends ResourceDependencies>(definition: LocalOnlyResourceDefinitionInput<Name, Handle, Scope, Dependencies> & {
164
+ readonly dependencies: Dependencies;
165
+ }): ResourceDefinition<Name, Handle, Dependencies>;
166
+ export declare function defineResource<const Name extends string, OwnerHandle, Projection extends ResourceProjectionPayload, ConsumerHandle, Scope extends 'per-file' | 'per-run' | 'per-suite', const Dependencies extends ResourceDependencies>(definition: ProjectedResourceDefinitionInput<Name, OwnerHandle, Projection, ConsumerHandle, Scope, Dependencies> & {
167
+ readonly dependencies: Dependencies;
168
+ }): ResourceDefinition<Name, OwnerHandle, Dependencies, ConsumerHandle>;
169
+ export declare function defineRuntime<const Name extends string, const Dimensions extends RuntimeDimensions, const Resources extends RuntimeResourceMap>(definition: RuntimeDefinitionInput<Name, Dimensions, Resources>): RuntimeDefinition<Name, Dimensions, Resources>;
170
+ declare function composeRuntimeContext<BaseContext extends Readonly<Record<string, unknown>>, Runtime extends RuntimeDefinition>(context: BaseContext & RuntimeScopeGuard<BaseContext, Runtime>, runtime: Runtime, resourceHandles: RuntimeContext<Runtime>): RuntimeContextComposition<BaseContext, Runtime>;
171
+ export declare function createResourcesModule(dependencies: ResourcesModuleDependencies): ResourcesModule;
172
+ export declare function isDefinedResource(resource: unknown): resource is AnyResourceDefinition;
173
+ export declare function isDefinedRuntime(runtime: unknown): runtime is RuntimeDefinition;
174
+ export {};
175
+ //# sourceMappingURL=resources.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"resources.d.ts","sourceRoot":"","sources":["../../../../source/resources/resources.ts"],"names":[],"mappings":"AAAA,QAAA,MAAM,uBAAuB,EAAE,OAAO,MAA8C,CAAC;AACrF,QAAA,MAAM,sBAAsB,EAAE,OAAO,MAA6C,CAAC;AAEnF,MAAM,MAAM,SAAS,CAAC,KAAK,IAAI,OAAO,CAAC,KAAK,CAAC,GAAG,KAAK,CAAC;AACtD,KAAK,OAAO,CAAC,MAAM,IAAI,MAAM,CAAC,MAAM,MAAM,CAAC,CAAC;AAC5C,KAAK,iBAAiB,GAAG;IAAE,QAAQ,CAAC,IAAI,EAAE,oBAAoB,CAAC;IAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;CAAE,CAAC;AACzF,KAAK,eAAe,GAAG;IAAE,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAC;CAAE,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ACzB,KAAK,CAAC,IAAI,SAAS,MAAM,EACzB,KAAK,CAAC,UAAU,SAAS,iBAAiB,EAC1C,KAAK,CAAC,SAAS,SAAS,kBAAkB,EAE1C,UAAU,EAAE,sBAAsB,CAAC,IAAI,EAAE,UAAU,EAAE,SAAS,CAAC,GAChE,iBAAiB,CAAC,IAAI,EAAE,UAAU,EAAE,SAAS,CAAC,CAShD;AAED,iBAAS,qBAAqB,CAC1B,WAAW,SAAS,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,EACrD,OAAO,SAAS,iBAAiB,EAEjC,OAAO,EAAE,WAAW,GAAG,iBAAiB,CAAC,WAAW,EAAE,OAAO,CAAC,EAC9D,OAAO,EAAE,OAAO,EAChB,eAAe,EAAE,cAAc,CAAC,OAAO,CAAC,GACzC,yBAAyB,CAAC,WAAW,EAAE,OAAO,CAAC,CAAC;AAyBnD,wBAAgB,qBAAqB,CAAC,YAAY,EAAE,2BAA2B,GAAG,eAAe,CAShG;AAED,wBAAgB,iBAAiB,CAAC,QAAQ,EAAE,OAAO,GAAG,QAAQ,IAAI,qBAAqB,CAItF;AAED,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,IAAI,iBAAiB,CAI/E"}
@@ -0,0 +1,9 @@
1
+ const resourceDefinitionBrand = Symbol('overkill.resourceDefinition');
2
+
3
+ export function isDefinedResource(resource) {
4
+ return typeof resource === 'object' &&
5
+ resource !== null &&
6
+ Reflect.get(resource, resourceDefinitionBrand) === true;
7
+ }
8
+
9
+ //# sourceMappingURL=resources.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"resources.js","sourceRoot":"","sources":["../../../../source/resources/resources.ts"],"names":[],"mappings":"AAAA,MAAM,uBAAuB,GAAkB,MAAM,CAAC,6BAA6B,CAAC,CAAC;AACF;AAoWnF,MAAM,kBAuBK,SAM8B,CAIrC,QAIyB;kBAQE,aAqCH,QAAQ;QA8B5B,QAAQ,KAAK,IAAI;QACjB,OAAO,CAAC,GAAG,CAAC,QAAQ,EAAE,uBAAuB,CAAC,KAAK,IAAI,CAAC;AAChE,CAAC"}
@@ -0,0 +1,37 @@
1
+ import type { AnyResourceDefinition, ResourceContext, RuntimeContext, RuntimeDefinition as RuntimeGraph, RuntimeResourceMap as ResourceMap } from '../resources/resources.ts';
2
+ import type { ResourceSession } from '../resources/resource-session.ts';
3
+ type DisposalContext = {
4
+ readonly signal: AbortSignal;
5
+ };
6
+ export type LifecycleMessages = {
7
+ readonly acquisitionFailure: string;
8
+ readonly disposalFailure: string;
9
+ };
10
+ type ResourceWrapperResourcesStep = {
11
+ readonly kind: 'resources';
12
+ readonly resources: ResourceMap;
13
+ };
14
+ type ResourceWrapperRuntimeStep = {
15
+ readonly kind: 'runtime';
16
+ readonly runtime: RuntimeGraph;
17
+ };
18
+ export type ResourceWrapperStep = ResourceWrapperResourcesStep | ResourceWrapperRuntimeStep;
19
+ export type ComposedResourceSession = {
20
+ readonly directResources: ResourceContext<ResourceMap>;
21
+ readonly disposeOnce: (context: DisposalContext) => Promise<void>;
22
+ readonly runtimeContexts: ReadonlyMap<RuntimeGraph, RuntimeContext<RuntimeGraph>>;
23
+ };
24
+ export type ResourceEntry = {
25
+ readonly key: string;
26
+ readonly resource: AnyResourceDefinition;
27
+ };
28
+ export declare function directResourceEntries(steps: readonly ResourceWrapperStep[]): readonly ResourceEntry[];
29
+ export declare function stepRuntimeGraphs(steps: readonly ResourceWrapperStep[]): readonly RuntimeGraph[];
30
+ export declare function resourceMapFromEntries(resourceEntries: readonly ResourceEntry[]): ResourceMap;
31
+ export declare function resourceContextForStep<Resources extends ResourceMap>(resources: Resources, handles: ResourceContext<ResourceMap>): ResourceContext<Resources>;
32
+ export declare function runtimeContextForStep<Graph extends RuntimeGraph>(runtime: Graph, session: ComposedResourceSession): RuntimeContext<Graph>;
33
+ export declare function combinedResourceEntries(steps: readonly ResourceWrapperStep[]): ResourceMap;
34
+ export declare function composedResourceSession(directResources: ResourceMap, runtimes: readonly RuntimeGraph[], session: ResourceSession<ResourceMap>): ComposedResourceSession;
35
+ export declare function lifecycleMessages(steps: readonly ResourceWrapperStep[]): LifecycleMessages;
36
+ export {};
37
+ //# sourceMappingURL=resource-lifecycle-composition.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"resource-lifecycle-composition.d.ts","sourceRoot":"","sources":["../../../../source/run/resource-lifecycle-composition.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACR,qBAAqB,EACrB,eAAe,EACf,cAAc,EACd,iBAAiB,IAAI,YAAY,EACjC,kBAAkB,IAAI,WAAW,EACpC,MAAM,2BAA2B,CAAC;AACnC,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,kCAAkC,CAAC;AAOxE,KAAK,eAAe,GAAG;IACnB,QAAQ,CAAC,MAAM,EAAE,WAAW,CAAC;CAChC,CAAC;AAEF,MAAM,MAAM,iBAAiB,GAAG;IAC5B,QAAQ,CAAC,kBAAkB,EAAE,MAAM,CAAC;IACpC,QAAQ,CAAC,eAAe,EAAE,MAAM,CAAC;CACpC,CAAC;AAEF,KAAK,4BAA4B,GAAG;IAChC,QAAQ,CAAC,IAAI,EAAE,WAAW,CAAC;IAC3B,QAAQ,CAAC,SAAS,EAAE,WAAW,CAAC;CACnC,CAAC;AAEF,KAAK,0BAA0B,GAAG;IAC9B,QAAQ,CAAC,IAAI,EAAE,SAAS,CAAC;IACzB,QAAQ,CAAC,OAAO,EAAE,YAAY,CAAC;CAClC,CAAC;AAEF,MAAM,MAAM,mBAAmB,GAAG,4BAA4B,GAAG,0BAA0B,CAAC;AAE5F,MAAM,MAAM,uBAAuB,GAAG;IAClC,QAAQ,CAAC,eAAe,EAAE,eAAe,CAAC,WAAW,CAAC,CAAC;IACvD,QAAQ,CAAC,WAAW,EAAE,CAAC,OAAO,EAAE,eAAe,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IAClE,QAAQ,CAAC,eAAe,EAAE,WAAW,CAAC,YAAY,E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