UNPKG

2.25 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 *
21 * @experimental
22 */
23export declare class DependencyGroup implements IDependable {
24 private readonly _deps;
25 constructor(...deps: IDependable[]);
26 /**
27 * Add a construct to the dependency roots
28 */
29 add(...scopes: IDependable[]): void;
30}
31/**
32 * Trait for IDependable
33 *
34 * Traits are interfaces that are privately implemented by objects. Instead of
35 * showing up in the public interface of a class, they need to be queried
36 * explicitly. This is used to implement certain framework features that are
37 * not intended to be used by Construct consumers, and so should be hidden
38 * from accidental use.
39 *
40 * @example
41 *
42 * // Usage
43 * const roots = Dependable.of(construct).dependencyRoots;
44 *
45 * // Definition
46 * Dependable.implement(construct, {
47 * dependencyRoots: [construct],
48 * });
49 *
50 * @experimental
51 */
52export declare abstract class Dependable {
53 /**
54 * Turn any object into an IDependable.
55 */
56 static implement(instance: IDependable, trait: Dependable): void;
57 /**
58 * Return the matching Dependable for the given class instance.
59 */
60 static of(instance: IDependable): Dependable;
61 /**
62 * Return the matching Dependable for the given class instance.
63 * @deprecated use `of`
64 */
65 static get(instance: IDependable): Dependable;
66 /**
67 * The set of constructs that form the root of this dependable
68 *
69 * All resources under all returned constructs are included in the ordering
70 * dependency.
71 */
72 abstract readonly dependencyRoots: IConstruct[];
73}