-
Notifications
You must be signed in to change notification settings - Fork 15
Expand file tree
/
Copy pathutil.extern.d.ts
More file actions
223 lines (216 loc) · 10.5 KB
/
Copy pathutil.extern.d.ts
File metadata and controls
223 lines (216 loc) · 10.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
export default interface extern {
buildAws: (options: BuildOptions) => string,
buildSim: (options: BuildOptions) => string,
dirname: () => string,
liftSim: (obj: Resource, options: LiftOptions, host: IInflightHost, clients: Record<string, LiftedSim>) => void,
liftTfAws: (id: string, client: Resource) => string,
}
export interface BuildOptions {
readonly handler: string;
readonly homeEnv: string;
readonly nodePath: string;
readonly path: string;
readonly pathEnv: string;
}
/** Trait marker for classes that can be depended upon.
The presence of this interface indicates that an object has
an `IDependable` implementation.
This interface can be used to take an (ordering) dependency on a set of
constructs. An ordering dependency implies that the resources represented by
those constructs are deployed before the resources depending ON them are
deployed. */
export interface IDependable {
}
/** Represents a construct. */
export interface IConstruct extends IDependable {
}
/** Represents the building block of the construct graph.
All constructs besides the root construct must be created within the scope of
another construct. */
export class Construct implements IConstruct {
/** Returns a string representation of this construct. */
readonly toString: () => string;
}
/** Data that can be lifted into inflight. */
export interface ILiftable {
}
/** A resource that can run inflight code. */
export interface IInflightHost extends IResource {
/** Adds an environment variable to the host. */
readonly addEnvironment: (name: string, value: string) => void;
}
/** A liftable object that needs to be registered on the host as part of the lifting process.
This is generally used so the host can set up permissions
to access the lifted object inflight. */
export interface IHostedLiftable extends ILiftable {
/** A hook called by the Wing compiler once for each inflight host that needs to use this object inflight.
The list of requested inflight methods
needed by the inflight host are given by `ops`.
This method is commonly used for adding permissions, environment variables, or
other capabilities to the inflight host. */
readonly onLift: (host: IInflightHost, ops: (readonly (string)[])) => void;
}
/** Options for `construct.addMetadata()`. */
export interface MetadataOptions {
/** Include stack trace with metadata entry. */
readonly stackTrace?: (boolean) | undefined;
/** A JavaScript function to begin tracing from.
This option is ignored unless `stackTrace` is `true`. */
readonly traceFromFunction?: (any) | undefined;
}
/** Implement this interface in order for the construct to be able to validate itself. */
export interface IValidation {
/** Validate the current construct.
This method can be implemented by derived constructs in order to perform
validation logic. It is called on all constructs before synthesis.
@returns An array of validation error messages, or an empty array if there the construct is valid. */
readonly validate: () => (readonly (string)[]);
}
/** In what order to return constructs. */
export enum ConstructOrder {
PREORDER = 0,
POSTORDER = 1,
}
/** An entry in the construct metadata table. */
export interface MetadataEntry {
/** The data. */
readonly data?: any;
/** Stack trace at the point of adding the metadata.
Only available if `addMetadata()` is called with `stackTrace: true`. */
readonly trace?: ((readonly (string)[])) | undefined;
/** The metadata entry type. */
readonly type: string;
}
/** Represents the construct node in the scope tree. */
export class Node {
/** Add an ordering dependency on another construct.
An `IDependable` */
readonly addDependency: (deps: (readonly (IDependable)[])) => void;
/** Adds a metadata entry to this construct.
Entries are arbitrary values and will also include a stack trace to allow tracing back to
the code location for when the entry was added. It can be used, for example, to include source
mapping in CloudFormation templates to improve diagnostics. */
readonly addMetadata: (type: string, data?: any, options?: (MetadataOptions) | undefined) => void;
/** Adds a validation to this construct.
When `node.validate()` is called, the `validate()` method will be called on
all validations and all errors will be returned. */
readonly addValidation: (validation: IValidation) => void;
/** Returns an opaque tree-unique address for this construct.
Addresses are 42 characters hexadecimal strings. They begin with "c8"
followed by 40 lowercase hexadecimal characters (0-9a-f).
Addresses are calculated using a SHA-1 of the components of the construct
path.
To enable refactorings of construct trees, constructs with the ID `Default`
will be excluded from the calculation. In those cases constructs in the
same tree may have the same addreess.
c83a2846e506bcc5f10682b564084bca2d275709ee */
readonly addr: string;
/** All direct children of this construct. */
readonly children: (readonly (IConstruct)[]);
/** Returns the child construct that has the id `Default` or `Resource"`.
This is usually the construct that provides the bulk of the underlying functionality.
Useful for modifications of the underlying construct that are not available at the higher levels.
Override the defaultChild property.
This should only be used in the cases where the correct
default child is not named 'Resource' or 'Default' as it
should be.
If you set this to undefined, the default behavior of finding
the child named 'Resource' or 'Default' will be used.
@returns a construct or undefined if there is no default child */
defaultChild?: (IConstruct) | undefined;
/** Return all dependencies registered on this node (non-recursive). */
readonly dependencies: (readonly (IConstruct)[]);
/** Return this construct and all of its children in the given order. */
readonly findAll: (order?: (ConstructOrder) | undefined) => (readonly (IConstruct)[]);
/** Return a direct child by id.
Throws an error if the child is not found.
@returns Child with the given id. */
readonly findChild: (id: string) => IConstruct;
/** Retrieves the all context of a node from tree context.
Context is usually initialized at the root, but can be overridden at any point in the tree.
@returns The context object or an empty object if there is discovered context */
readonly getAllContext: (defaults?: (Readonly<any>) | undefined) => any;
/** Retrieves a value from tree context if present. Otherwise, would throw an error.
Context is usually initialized at the root, but can be overridden at any point in the tree.
@returns The context value or throws error if there is no context value for this key */
readonly getContext: (key: string) => any;
/** The id of this construct within the current scope.
This is a scope-unique id. To obtain an app-unique id for this construct, use `addr`. */
readonly id: string;
/** Locks this construct from allowing more children to be added.
After this
call, no more children can be added to this construct or to any children. */
readonly lock: () => void;
/** Returns true if this construct or the scopes in which it is defined are locked. */
readonly locked: boolean;
/** An immutable array of metadata objects associated with this construct.
This can be used, for example, to implement support for deprecation notices, source mapping, etc. */
readonly metadata: (readonly (MetadataEntry)[]);
/** The full, absolute path of this construct in the tree.
Components are separated by '/'. */
readonly path: string;
/** Returns the root of the construct tree.
@returns The root of the construct tree. */
readonly root: IConstruct;
/** Returns the scope in which this construct is defined.
The value is `undefined` at the root of the construct scope tree. */
readonly scope?: (IConstruct) | undefined;
/** All parent scopes of this construct.
@returns a list of parent scopes. The last element in the list will always
be the current construct and the first element will be the root of the
tree. */
readonly scopes: (readonly (IConstruct)[]);
/** This can be used to set contextual values.
Context must be set before any children are added, since children may consult context info during construction.
If the key already exists, it will be overridden. */
readonly setContext: (key: string, value?: any) => void;
/** Return a direct child by id, or undefined.
@returns the child if found, or undefined */
readonly tryFindChild: (id: string) => IConstruct | void;
/** Retrieves a value from tree context.
Context is usually initialized at the root, but can be overridden at any point in the tree.
@returns The context value or `undefined` if there is no context value for this key. */
readonly tryGetContext: (key: string) => any;
/** Remove the child with the given name, if present.
@returns Whether a child with the given name was deleted. */
readonly tryRemoveChild: (childName: string) => boolean;
/** Validates this construct.
Invokes the `validate()` method on all validations added through
`addValidation()`.
@returns an array of validation error messages associated with this
construct. */
readonly validate: () => (readonly (string)[]);
}
/** Abstract interface for `Resource`. */
export interface IResource extends IConstruct, IHostedLiftable {
/** The tree node. */
readonly node: Node;
/** A hook called by the Wing compiler once for each inflight host that needs to use this object inflight.
The list of requested inflight methods
needed by the inflight host are given by `ops`.
This method is commonly used for adding permissions, environment variables, or
other capabilities to the inflight host. */
readonly onLift: (host: IInflightHost, ops: (readonly (string)[])) => void;
}
/** Shared behavior between all Wing SDK resources. */
export class Resource extends Construct implements IResource {
/** A hook called by the Wing compiler once for each inflight host that needs to use this resource inflight.
You can override this method to perform additional logic like granting
IAM permissions to the host based on what methods are being called. But
you must call `super.bind(host, ops)` to ensure that the resource is
actually bound. */
readonly onLift: (host: IInflightHost, ops: (readonly (string)[])) => void;
}
export interface LiftOptions {
readonly allow: (readonly (string)[]);
readonly id: string;
}
export interface LiftedSim {
readonly children?: (Readonly<Record<string, LiftedSim>>) | undefined;
readonly handle: string;
readonly id: string;
readonly path: string;
readonly props?: (Readonly<any>) | undefined;
readonly target: string;
readonly type: string;
}