UNPKG

2.21 kBTypeScriptView Raw
1import { IConstruct } from './construct';
2/**
3 * Trait marker for classes that can be depended upon
4 *
5 * The presence of this interface indicates that an object has
6 * an `IDependable` implementation.
7 *
8 * This interface can be used to take an (ordering) dependency on a set of
9 * constructs. An ordering dependency implies that the resources represented by
10 * those constructs are deployed before the resources depending ON them are
11 * deployed.
12 */
13export interface IDependable {
14}
15/**
16 * A set of constructs to be used as a dependable
17 *
18 * This class can be used when a set of constructs which are disjoint in the
19 * construct tree needs to be combined to be used as a single dependable.
20 */
21export declare class DependencyGroup implements IDependable {
22 private readonly _deps;
23 constructor(...deps: IDependable[]);
24 /**
25 * Add a construct to the dependency roots
26 */
27 add(...scopes: IDependable[]): void;
28}
29/**
30 * Trait for IDependable
31 *
32 * Traits are interfaces that are privately implemented by objects. Instead of
33 * showing up in the public interface of a class, they need to be queried
34 * explicitly. This is used to implement certain framework features that are
35 * not intended to be used by Construct consumers, and so should be hidden
36 * from accidental use.
37 *
38 * @example
39 *
40 * // Usage
41 * const roots = Dependable.of(construct).dependencyRoots;
42 *
43 * // Definition
44 * Dependable.implement(construct, {
45 * dependencyRoots: [construct],
46 * });
47 */
48export declare abstract class Dependable {
49 /**
50 * Turn any object into an IDependable.
51 */
52 static implement(instance: IDependable, trait: Dependable): void;
53 /**
54 * Return the matching Dependable for the given class instance.
55 */
56 static of(instance: IDependable): Dependable;
57 /**
58 * Return the matching Dependable for the given class instance.
59 * @deprecated use `of`
60 */
61 static get(instance: IDependable): Dependable;
62 /**
63 * The set of constructs that form the root of this dependable
64 *
65 * All resources under all returned constructs are included in the ordering
66 * dependency.
67 */
68 abstract readonly dependencyRoots: IConstruct[];
69}