codify-plugin-lib 1.0.69 → 1.0.70
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.
|
@@ -23,7 +23,7 @@ export declare abstract class Resource<T extends StringIndexedObject> {
|
|
|
23
23
|
protected schemaValidator?: ValidateFunction;
|
|
24
24
|
protected constructor(options: ResourceOptions<T>);
|
|
25
25
|
onInitialize(): Promise<void>;
|
|
26
|
-
validateResource(parameters:
|
|
26
|
+
validateResource(parameters: Partial<T>): Promise<ValidationResult>;
|
|
27
27
|
plan(desiredConfig: Partial<T> & ResourceConfig | null, currentConfig?: Partial<T> & ResourceConfig | null, statefulMode?: boolean): Promise<Plan<T>>;
|
|
28
28
|
apply(plan: Plan<T>): Promise<void>;
|
|
29
29
|
private _applyCreate;
|
|
@@ -35,8 +35,8 @@ export declare abstract class Resource<T extends StringIndexedObject> {
|
|
|
35
35
|
private refreshNonStatefulParameters;
|
|
36
36
|
private refreshStatefulParameters;
|
|
37
37
|
private validatePlanInputs;
|
|
38
|
-
validate(parameters:
|
|
39
|
-
abstract refresh(values:
|
|
38
|
+
validate(parameters: Partial<T>): Promise<ValidationResult>;
|
|
39
|
+
abstract refresh(values: Partial<T>): Promise<Partial<T> | null>;
|
|
40
40
|
abstract applyCreate(plan: CreatePlan<T>): Promise<void>;
|
|
41
41
|
applyModify(pc: ParameterChange<T>, plan: ModifyPlan<T>): Promise<void>;
|
|
42
42
|
abstract applyDestroy(plan: DestroyPlan<T>): Promise<void>;
|
|
@@ -139,11 +139,11 @@ export class Resource {
|
|
|
139
139
|
}
|
|
140
140
|
await this.applyDestroy(plan);
|
|
141
141
|
}
|
|
142
|
-
validateRefreshResults(refresh,
|
|
142
|
+
validateRefreshResults(refresh, desired) {
|
|
143
143
|
if (!refresh) {
|
|
144
144
|
return;
|
|
145
145
|
}
|
|
146
|
-
const desiredKeys = new Set(
|
|
146
|
+
const desiredKeys = new Set(Object.keys(refresh));
|
|
147
147
|
const refreshKeys = new Set(Object.keys(refresh));
|
|
148
148
|
if (!setsEqual(desiredKeys, refreshKeys)) {
|
|
149
149
|
throw new Error(`Resource ${this.typeId}
|
|
@@ -184,9 +184,8 @@ Additional: ${[...refreshKeys].filter(k => !desiredKeys.has(k))};`);
|
|
|
184
184
|
});
|
|
185
185
|
}
|
|
186
186
|
async refreshNonStatefulParameters(resourceParameters) {
|
|
187
|
-
const
|
|
188
|
-
|
|
189
|
-
this.validateRefreshResults(currentParameters, entriesToRefresh);
|
|
187
|
+
const currentParameters = await this.refresh(resourceParameters);
|
|
188
|
+
this.validateRefreshResults(currentParameters, resourceParameters);
|
|
190
189
|
return currentParameters;
|
|
191
190
|
}
|
|
192
191
|
async refreshStatefulParameters(statefulParametersConfig, isStatefulMode) {
|
package/package.json
CHANGED
package/src/entities/errors.ts
CHANGED
package/src/entities/plugin.ts
CHANGED
package/src/entities/resource.ts
CHANGED
|
@@ -59,7 +59,7 @@ export abstract class Resource<T extends StringIndexedObject> {
|
|
|
59
59
|
|
|
60
60
|
async onInitialize(): Promise<void> {}
|
|
61
61
|
|
|
62
|
-
async validateResource(parameters:
|
|
62
|
+
async validateResource(parameters: Partial<T>): Promise<ValidationResult> {
|
|
63
63
|
if (this.schemaValidator) {
|
|
64
64
|
const isValid = this.schemaValidator(parameters);
|
|
65
65
|
|
|
@@ -215,12 +215,12 @@ export abstract class Resource<T extends StringIndexedObject> {
|
|
|
215
215
|
await this.applyDestroy(plan as DestroyPlan<T>);
|
|
216
216
|
}
|
|
217
217
|
|
|
218
|
-
private validateRefreshResults(refresh: Partial<T> | null,
|
|
218
|
+
private validateRefreshResults(refresh: Partial<T> | null, desired: Partial<T>) {
|
|
219
219
|
if (!refresh) {
|
|
220
220
|
return;
|
|
221
221
|
}
|
|
222
222
|
|
|
223
|
-
const desiredKeys = new Set
|
|
223
|
+
const desiredKeys = new Set(Object.keys(refresh)) as Set<keyof T>;
|
|
224
224
|
const refreshKeys = new Set(Object.keys(refresh)) as Set<keyof T>;
|
|
225
225
|
|
|
226
226
|
if (!setsEqual(desiredKeys, refreshKeys)) {
|
|
@@ -278,11 +278,8 @@ Additional: ${[...refreshKeys].filter(k => !desiredKeys.has(k))};`
|
|
|
278
278
|
}
|
|
279
279
|
|
|
280
280
|
private async refreshNonStatefulParameters(resourceParameters: Partial<T>): Promise<Partial<T> | null> {
|
|
281
|
-
const
|
|
282
|
-
|
|
283
|
-
)
|
|
284
|
-
const currentParameters = await this.refresh(entriesToRefresh);
|
|
285
|
-
this.validateRefreshResults(currentParameters, entriesToRefresh);
|
|
281
|
+
const currentParameters = await this.refresh(resourceParameters);
|
|
282
|
+
this.validateRefreshResults(currentParameters, resourceParameters);
|
|
286
283
|
return currentParameters;
|
|
287
284
|
}
|
|
288
285
|
|
|
@@ -340,13 +337,13 @@ Additional: ${[...refreshKeys].filter(k => !desiredKeys.has(k))};`
|
|
|
340
337
|
}
|
|
341
338
|
}
|
|
342
339
|
|
|
343
|
-
async validate(parameters:
|
|
340
|
+
async validate(parameters: Partial<T>): Promise<ValidationResult> {
|
|
344
341
|
return {
|
|
345
342
|
isValid: true,
|
|
346
343
|
}
|
|
347
344
|
};
|
|
348
345
|
|
|
349
|
-
abstract refresh(values:
|
|
346
|
+
abstract refresh(values: Partial<T>): Promise<Partial<T> | null>;
|
|
350
347
|
|
|
351
348
|
abstract applyCreate(plan: CreatePlan<T>): Promise<void>;
|
|
352
349
|
|