@terraforge/terraform 0.0.10 → 0.0.12

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.
@@ -0,0 +1,309 @@
1
+ //#region src/plugin/schema.d.ts
2
+
3
+ type Property = {
4
+ description?: string;
5
+ required?: boolean;
6
+ optional?: boolean;
7
+ /** The computed field means that it could be computed by the server. */
8
+ computed?: boolean;
9
+ deprecated?: boolean;
10
+ sensitive?: boolean;
11
+ } & ({
12
+ type: 'string' | 'number' | 'boolean';
13
+ } | {
14
+ type: 'array' | 'record';
15
+ item: Property;
16
+ } | {
17
+ type: 'object' | 'array-object';
18
+ properties: Record<string, Property>;
19
+ } | {
20
+ type: 'unknown';
21
+ });
22
+ //#endregion
23
+ //#region src/type-gen.d.ts
24
+ declare const generateTypes: (namespace: string, provider: Property, resources: Record<string, Property>, dataSources: Record<string, Property>) => string;
25
+ //#endregion
26
+ //#region src/plugin/version/type.d.ts
27
+ type State$1 = Record<string, unknown>;
28
+ type Plugin = Readonly<{
29
+ schema: () => {
30
+ provider: Property;
31
+ resources: Record<string, Property>;
32
+ dataSources: Record<string, Property>;
33
+ };
34
+ stop: () => Promise<void>;
35
+ configure: (config: State$1) => Promise<void>;
36
+ readResource: (type: string, state: State$1) => Promise<State$1>;
37
+ readDataSource: (type: string, state: State$1) => Promise<State$1>;
38
+ validateResource: (type: string, state: State$1) => Promise<void>;
39
+ planResourceChange: (type: string, priorState: State$1 | null, proposedNewState: State$1 | null) => Promise<{
40
+ requiresReplace: Array<string | number>[];
41
+ plannedState: State$1;
42
+ }>;
43
+ applyResourceChange: (type: string, priorState: State$1 | null, proposedNewState: State$1 | null) => Promise<State$1>;
44
+ }>;
45
+ //#endregion
46
+ //#region ../core/src/future.d.ts
47
+ declare class Future<T = unknown> {
48
+ protected callback: (resolve: (data: T) => void, reject: (error: unknown) => void) => void;
49
+ protected listeners: Set<{
50
+ resolve: (data: T) => void;
51
+ reject?: (error: unknown) => void;
52
+ }>;
53
+ protected status: 0 | 1 | 2 | 3;
54
+ protected data?: T;
55
+ protected error?: unknown;
56
+ constructor(callback: (resolve: (data: T) => void, reject: (error: unknown) => void) => void);
57
+ get [Symbol.toStringTag](): string;
58
+ pipe<N>(cb: (value: T) => N): Future<Awaited<N>>;
59
+ then(resolve: (data: T) => void, reject?: (error: unknown) => void): void;
60
+ }
61
+ //#endregion
62
+ //#region ../core/src/input.d.ts
63
+ type Input<T = unknown> = T | Output<T> | Future<T> | Promise<T>;
64
+ type UnwrapInputArray<T extends Input[]> = { [K in keyof T]: UnwrapInput<T[K]> };
65
+ type UnwrapInput<T> = T extends Input<infer V> ? V : T;
66
+ //#endregion
67
+ //#region ../core/src/output.d.ts
68
+ declare class Output<T = unknown> extends Future<T> {
69
+ readonly dependencies: Set<Meta>;
70
+ constructor(dependencies: Set<Meta>, callback: (resolve: (data: T) => void, reject: (error: unknown) => void) => void);
71
+ pipe<N>(cb: (value: T) => N): Output<Awaited<N>>;
72
+ }
73
+ declare const combine: <T extends Input[], R = UnwrapInputArray<T>>(...inputs: T) => Output<R>;
74
+ declare const resolve: <T extends [Input, ...Input[]], R>(inputs: T, transformer: (...inputs: UnwrapInputArray<T>) => R) => Output<Awaited<R>>;
75
+ declare const interpolate: (literals: TemplateStringsArray, ...placeholders: Input<any>[]) => Output<string>;
76
+ //#endregion
77
+ //#region ../core/src/urn.d.ts
78
+ type URN = `urn:${string}`;
79
+ //#endregion
80
+ //#region ../core/src/node.d.ts
81
+ declare const nodeMetaSymbol: unique symbol;
82
+ type Node<T extends Tag = Tag, O extends State = State> = {
83
+ readonly [nodeMetaSymbol]: Meta<T>;
84
+ readonly urn: URN;
85
+ } & O;
86
+ //#endregion
87
+ //#region ../core/src/resource.d.ts
88
+ type ResourceConfig = Config & {
89
+ /** Import an existing resource instead of creating a new resource. */
90
+ import?: string;
91
+ /** If true the resource will be retained in the backing cloud provider during a delete operation. */
92
+ retainOnDelete?: boolean;
93
+ /** If set, the provider’s Delete method will not be called for this resource if the specified resource is being deleted as well. */
94
+ /** Declare that changes to certain properties should be treated as forcing a replacement. */
95
+ replaceOnChanges?: string[];
96
+ /** If true, create the replacement before deleting the existing resource. */
97
+ createBeforeReplace?: boolean;
98
+ };
99
+ type ResourceMeta = Meta<'resource', ResourceConfig>;
100
+ type Resource<O extends State = State> = O & {
101
+ readonly [nodeMetaSymbol]: ResourceMeta;
102
+ readonly urn: URN;
103
+ };
104
+ //#endregion
105
+ //#region ../core/src/stack.d.ts
106
+ declare class Stack extends Group {
107
+ readonly app: App;
108
+ readonly dependencies: Set<Stack>;
109
+ constructor(app: App, name: string);
110
+ }
111
+ //#endregion
112
+ //#region ../core/src/meta.d.ts
113
+ type Tag = 'resource' | 'data';
114
+ type State = Record<string, any>;
115
+ type Config = {
116
+ /** Specify additional explicit dependencies in addition to the ones in the dependency graph. */
117
+ dependsOn?: Array<Resource | DataSource>;
118
+ /** Pass an ID of an explicitly configured provider, instead of using the default provider. */
119
+ provider?: string;
120
+ };
121
+ type Meta<T extends Tag = Tag, C extends Config = Config> = {
122
+ readonly tag: T;
123
+ readonly urn: URN;
124
+ readonly logicalId: string;
125
+ readonly type: string;
126
+ readonly stack: Stack;
127
+ readonly provider: string;
128
+ readonly input: State;
129
+ readonly config?: C;
130
+ readonly dependencies: Set<URN>;
131
+ readonly resolve: (data: State) => void;
132
+ readonly output: <V>(cb: (data: State) => V) => Output<V>;
133
+ };
134
+ //#endregion
135
+ //#region ../core/src/data-source.d.ts
136
+ type DataSourceMeta = Meta<'data'>;
137
+ type DataSource<O extends State = State> = {
138
+ readonly [nodeMetaSymbol]: DataSourceMeta;
139
+ readonly urn: URN;
140
+ } & O;
141
+ //#endregion
142
+ //#region ../core/src/group.d.ts
143
+ declare class Group {
144
+ readonly parent: Group | undefined;
145
+ readonly type: string;
146
+ readonly name: string;
147
+ protected children: Array<Group | Node>;
148
+ constructor(parent: Group | undefined, type: string, name: string);
149
+ get urn(): URN;
150
+ protected addChild(child: Group | Node): void;
151
+ add(...children: Array<Group | Node>): void;
152
+ get nodes(): Node[];
153
+ get resources(): Resource[];
154
+ get dataSources(): DataSource[];
155
+ }
156
+ //#endregion
157
+ //#region ../core/src/app.d.ts
158
+ declare class App extends Group {
159
+ readonly name: string;
160
+ constructor(name: string);
161
+ get stacks(): Stack[];
162
+ }
163
+ //#endregion
164
+ //#region ../core/src/provider.d.ts
165
+ type CreateProps<T = State> = {
166
+ type: string;
167
+ state: T;
168
+ idempotantToken?: string;
169
+ };
170
+ type UpdateProps<T = State> = {
171
+ type: string;
172
+ priorState: T;
173
+ proposedState: T;
174
+ idempotantToken?: string;
175
+ };
176
+ type DeleteProps<T = State> = {
177
+ type: string;
178
+ state: T;
179
+ idempotantToken?: string;
180
+ };
181
+ type PlanProps<T = State> = {
182
+ type: string;
183
+ priorState: T;
184
+ proposedState: T;
185
+ };
186
+ type GetProps<T = State> = {
187
+ type: string;
188
+ state: T;
189
+ };
190
+ type GetDataProps<T = State> = {
191
+ type: string;
192
+ state: T;
193
+ };
194
+ interface Provider {
195
+ ownResource(id: string): boolean;
196
+ getResource(props: GetProps): Promise<{
197
+ version: number;
198
+ state: State;
199
+ }>;
200
+ createResource(props: CreateProps): Promise<{
201
+ version: number;
202
+ state: State;
203
+ }>;
204
+ updateResource(props: UpdateProps): Promise<{
205
+ version: number;
206
+ state: State;
207
+ }>;
208
+ deleteResource(props: DeleteProps): Promise<void>;
209
+ planResourceChange?(props: PlanProps): Promise<{
210
+ version: number;
211
+ state: State;
212
+ requiresReplacement: boolean;
213
+ }>;
214
+ getData?(props: GetDataProps): Promise<{
215
+ state: State;
216
+ }>;
217
+ destroy?(): Promise<void>;
218
+ }
219
+ //#endregion
220
+ //#region ../core/src/helpers.d.ts
221
+ declare const file: (path: string, encoding?: BufferEncoding) => Future<string>;
222
+ declare const hash: (path: string, algo?: string) => Future<string>;
223
+ //#endregion
224
+ //#region ../core/src/globals.d.ts
225
+ declare global {
226
+ var $resolve: typeof resolve;
227
+ var $combine: typeof combine;
228
+ var $interpolate: typeof interpolate;
229
+ var $hash: typeof hash;
230
+ var $file: typeof file;
231
+ }
232
+ //#endregion
233
+ //#region src/provider.d.ts
234
+ declare class TerraformProvider implements Provider {
235
+ private type;
236
+ private id;
237
+ private createPlugin;
238
+ private config;
239
+ private configured?;
240
+ private plugin?;
241
+ constructor(type: string, id: string, createPlugin: () => Promise<Plugin>, config: State);
242
+ private configure;
243
+ private prepare;
244
+ destroy(): Promise<void>;
245
+ ownResource(id: string): boolean;
246
+ getResource({
247
+ type,
248
+ state
249
+ }: GetProps): Promise<{
250
+ version: number;
251
+ state: State$1;
252
+ }>;
253
+ createResource({
254
+ type,
255
+ state
256
+ }: CreateProps): Promise<{
257
+ version: number;
258
+ state: State$1;
259
+ }>;
260
+ updateResource({
261
+ type,
262
+ priorState,
263
+ proposedState
264
+ }: UpdateProps): Promise<{
265
+ version: number;
266
+ state: State$1;
267
+ }>;
268
+ deleteResource({
269
+ type,
270
+ state
271
+ }: DeleteProps): Promise<void>;
272
+ planResourceChange({
273
+ type,
274
+ priorState,
275
+ proposedState
276
+ }: PlanProps): Promise<{
277
+ version: number;
278
+ requiresReplacement: boolean;
279
+ state: State$1;
280
+ }>;
281
+ getData({
282
+ type,
283
+ state
284
+ }: GetDataProps): Promise<{
285
+ state: State$1;
286
+ }>;
287
+ }
288
+ //#endregion
289
+ //#region src/plugin/registry.d.ts
290
+ type Version = `${number}.${number}.${number}` | 'latest';
291
+ //#endregion
292
+ //#region src/proxy.d.ts
293
+ type TerraformProviderConfig = {
294
+ id?: string;
295
+ location?: string;
296
+ };
297
+ type InstallProps = {
298
+ location?: string;
299
+ };
300
+ declare const createTerraformProxy: (props: {
301
+ namespace: string;
302
+ provider: {
303
+ org: string;
304
+ type: string;
305
+ version: Version;
306
+ };
307
+ }) => () => void;
308
+ //#endregion
309
+ export { type InstallProps, TerraformProvider, type TerraformProviderConfig, createTerraformProxy, generateTypes };