@terraforge/terraform 0.0.10 → 0.0.11
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.
- package/dist/index.d.mts +310 -0
- package/dist/index.mjs +2367 -0
- package/package.json +7 -7
- package/dist/index.d.ts +0 -97
- package/dist/index.js +0 -1996
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,310 @@
|
|
|
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
|
+
dependsOn(...stacks: Stack[]): this;
|
|
111
|
+
}
|
|
112
|
+
//#endregion
|
|
113
|
+
//#region ../core/src/meta.d.ts
|
|
114
|
+
type Tag = 'resource' | 'data';
|
|
115
|
+
type State = Record<string, any>;
|
|
116
|
+
type Config = {
|
|
117
|
+
/** Specify additional explicit dependencies in addition to the ones in the dependency graph. */
|
|
118
|
+
dependsOn?: Resource[];
|
|
119
|
+
/** Pass an ID of an explicitly configured provider, instead of using the default provider. */
|
|
120
|
+
provider?: string;
|
|
121
|
+
};
|
|
122
|
+
type Meta<T extends Tag = Tag, C extends Config = Config> = {
|
|
123
|
+
readonly tag: T;
|
|
124
|
+
readonly urn: URN;
|
|
125
|
+
readonly logicalId: string;
|
|
126
|
+
readonly type: string;
|
|
127
|
+
readonly stack: Stack;
|
|
128
|
+
readonly provider: string;
|
|
129
|
+
readonly input: State;
|
|
130
|
+
readonly config?: C;
|
|
131
|
+
readonly dependencies: Set<URN>;
|
|
132
|
+
readonly resolve: (data: State) => void;
|
|
133
|
+
readonly output: <V>(cb: (data: State) => V) => Output<V>;
|
|
134
|
+
};
|
|
135
|
+
//#endregion
|
|
136
|
+
//#region ../core/src/data-source.d.ts
|
|
137
|
+
type DataSourceMeta = Meta<'data'>;
|
|
138
|
+
type DataSource<O extends State = State> = {
|
|
139
|
+
readonly [nodeMetaSymbol]: DataSourceMeta;
|
|
140
|
+
readonly urn: URN;
|
|
141
|
+
} & O;
|
|
142
|
+
//#endregion
|
|
143
|
+
//#region ../core/src/group.d.ts
|
|
144
|
+
declare class Group {
|
|
145
|
+
readonly parent: Group | undefined;
|
|
146
|
+
readonly type: string;
|
|
147
|
+
readonly name: string;
|
|
148
|
+
protected children: Array<Group | Node>;
|
|
149
|
+
constructor(parent: Group | undefined, type: string, name: string);
|
|
150
|
+
get urn(): URN;
|
|
151
|
+
protected addChild(child: Group | Node): void;
|
|
152
|
+
add(...children: Array<Group | Node>): void;
|
|
153
|
+
get nodes(): Node[];
|
|
154
|
+
get resources(): Resource[];
|
|
155
|
+
get dataSources(): DataSource[];
|
|
156
|
+
}
|
|
157
|
+
//#endregion
|
|
158
|
+
//#region ../core/src/app.d.ts
|
|
159
|
+
declare class App extends Group {
|
|
160
|
+
readonly name: string;
|
|
161
|
+
constructor(name: string);
|
|
162
|
+
get stacks(): Stack[];
|
|
163
|
+
}
|
|
164
|
+
//#endregion
|
|
165
|
+
//#region ../core/src/provider.d.ts
|
|
166
|
+
type CreateProps<T = State> = {
|
|
167
|
+
type: string;
|
|
168
|
+
state: T;
|
|
169
|
+
idempotantToken?: string;
|
|
170
|
+
};
|
|
171
|
+
type UpdateProps<T = State> = {
|
|
172
|
+
type: string;
|
|
173
|
+
priorState: T;
|
|
174
|
+
proposedState: T;
|
|
175
|
+
idempotantToken?: string;
|
|
176
|
+
};
|
|
177
|
+
type DeleteProps<T = State> = {
|
|
178
|
+
type: string;
|
|
179
|
+
state: T;
|
|
180
|
+
idempotantToken?: string;
|
|
181
|
+
};
|
|
182
|
+
type PlanProps<T = State> = {
|
|
183
|
+
type: string;
|
|
184
|
+
priorState: T;
|
|
185
|
+
proposedState: T;
|
|
186
|
+
};
|
|
187
|
+
type GetProps<T = State> = {
|
|
188
|
+
type: string;
|
|
189
|
+
state: T;
|
|
190
|
+
};
|
|
191
|
+
type GetDataProps<T = State> = {
|
|
192
|
+
type: string;
|
|
193
|
+
state: T;
|
|
194
|
+
};
|
|
195
|
+
interface Provider {
|
|
196
|
+
ownResource(id: string): boolean;
|
|
197
|
+
getResource(props: GetProps): Promise<{
|
|
198
|
+
version: number;
|
|
199
|
+
state: State;
|
|
200
|
+
}>;
|
|
201
|
+
createResource(props: CreateProps): Promise<{
|
|
202
|
+
version: number;
|
|
203
|
+
state: State;
|
|
204
|
+
}>;
|
|
205
|
+
updateResource(props: UpdateProps): Promise<{
|
|
206
|
+
version: number;
|
|
207
|
+
state: State;
|
|
208
|
+
}>;
|
|
209
|
+
deleteResource(props: DeleteProps): Promise<void>;
|
|
210
|
+
planResourceChange?(props: PlanProps): Promise<{
|
|
211
|
+
version: number;
|
|
212
|
+
state: State;
|
|
213
|
+
requiresReplacement: boolean;
|
|
214
|
+
}>;
|
|
215
|
+
getData?(props: GetDataProps): Promise<{
|
|
216
|
+
state: State;
|
|
217
|
+
}>;
|
|
218
|
+
destroy?(): Promise<void>;
|
|
219
|
+
}
|
|
220
|
+
//#endregion
|
|
221
|
+
//#region ../core/src/helpers.d.ts
|
|
222
|
+
declare const file: (path: string, encoding?: BufferEncoding) => Future<string>;
|
|
223
|
+
declare const hash: (path: string, algo?: string) => Future<string>;
|
|
224
|
+
//#endregion
|
|
225
|
+
//#region ../core/src/globals.d.ts
|
|
226
|
+
declare global {
|
|
227
|
+
var $resolve: typeof resolve;
|
|
228
|
+
var $combine: typeof combine;
|
|
229
|
+
var $interpolate: typeof interpolate;
|
|
230
|
+
var $hash: typeof hash;
|
|
231
|
+
var $file: typeof file;
|
|
232
|
+
}
|
|
233
|
+
//#endregion
|
|
234
|
+
//#region src/provider.d.ts
|
|
235
|
+
declare class TerraformProvider implements Provider {
|
|
236
|
+
private type;
|
|
237
|
+
private id;
|
|
238
|
+
private createPlugin;
|
|
239
|
+
private config;
|
|
240
|
+
private configured?;
|
|
241
|
+
private plugin?;
|
|
242
|
+
constructor(type: string, id: string, createPlugin: () => Promise<Plugin>, config: State);
|
|
243
|
+
private configure;
|
|
244
|
+
private prepare;
|
|
245
|
+
destroy(): Promise<void>;
|
|
246
|
+
ownResource(id: string): boolean;
|
|
247
|
+
getResource({
|
|
248
|
+
type,
|
|
249
|
+
state
|
|
250
|
+
}: GetProps): Promise<{
|
|
251
|
+
version: number;
|
|
252
|
+
state: State$1;
|
|
253
|
+
}>;
|
|
254
|
+
createResource({
|
|
255
|
+
type,
|
|
256
|
+
state
|
|
257
|
+
}: CreateProps): Promise<{
|
|
258
|
+
version: number;
|
|
259
|
+
state: State$1;
|
|
260
|
+
}>;
|
|
261
|
+
updateResource({
|
|
262
|
+
type,
|
|
263
|
+
priorState,
|
|
264
|
+
proposedState
|
|
265
|
+
}: UpdateProps): Promise<{
|
|
266
|
+
version: number;
|
|
267
|
+
state: State$1;
|
|
268
|
+
}>;
|
|
269
|
+
deleteResource({
|
|
270
|
+
type,
|
|
271
|
+
state
|
|
272
|
+
}: DeleteProps): Promise<void>;
|
|
273
|
+
planResourceChange({
|
|
274
|
+
type,
|
|
275
|
+
priorState,
|
|
276
|
+
proposedState
|
|
277
|
+
}: PlanProps): Promise<{
|
|
278
|
+
version: number;
|
|
279
|
+
requiresReplacement: boolean;
|
|
280
|
+
state: State$1;
|
|
281
|
+
}>;
|
|
282
|
+
getData({
|
|
283
|
+
type,
|
|
284
|
+
state
|
|
285
|
+
}: GetDataProps): Promise<{
|
|
286
|
+
state: State$1;
|
|
287
|
+
}>;
|
|
288
|
+
}
|
|
289
|
+
//#endregion
|
|
290
|
+
//#region src/plugin/registry.d.ts
|
|
291
|
+
type Version = `${number}.${number}.${number}` | 'latest';
|
|
292
|
+
//#endregion
|
|
293
|
+
//#region src/proxy.d.ts
|
|
294
|
+
type TerraformProviderConfig = {
|
|
295
|
+
id?: string;
|
|
296
|
+
location?: string;
|
|
297
|
+
};
|
|
298
|
+
type InstallProps = {
|
|
299
|
+
location?: string;
|
|
300
|
+
};
|
|
301
|
+
declare const createTerraformProxy: (props: {
|
|
302
|
+
namespace: string;
|
|
303
|
+
provider: {
|
|
304
|
+
org: string;
|
|
305
|
+
type: string;
|
|
306
|
+
version: Version;
|
|
307
|
+
};
|
|
308
|
+
}) => () => void;
|
|
309
|
+
//#endregion
|
|
310
|
+
export { type InstallProps, TerraformProvider, type TerraformProviderConfig, createTerraformProxy, generateTypes };
|