codify-plugin-lib 1.0.82 → 1.0.84

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.
@@ -73,7 +73,7 @@ export class ResourceController {
73
73
  await this.applyTransformParameters(desiredConfig);
74
74
  // Parse data from the user supplied config
75
75
  const parsedConfig = new ConfigParser(desiredConfig, stateConfig, this.parsedSettings.statefulParameters);
76
- const { coreParameters, desiredParameters, stateParameters, allNonStatefulParameters, allStatefulParameters, } = parsedConfig;
76
+ const { coreParameters, desiredParameters, stateParameters, allParameters, allNonStatefulParameters, allStatefulParameters, } = parsedConfig;
77
77
  // Refresh resource parameters. This refreshes the parameters that configure the resource itself
78
78
  const currentParametersArray = await this.refreshNonStatefulParameters(allNonStatefulParameters);
79
79
  // Short circuit here. If the resource is non-existent, there's no point checking stateful parameters
@@ -93,7 +93,7 @@ export class ResourceController {
93
93
  }
94
94
  // Refresh stateful parameters. These parameters have state external to the resource. allowMultiple
95
95
  // does not work together with stateful parameters
96
- const statefulCurrentParameters = await this.refreshStatefulParameters(allStatefulParameters);
96
+ const statefulCurrentParameters = await this.refreshStatefulParameters(allStatefulParameters, allParameters);
97
97
  return Plan.calculate({
98
98
  desiredParameters,
99
99
  currentParametersArray: [{ ...currentParametersArray[0], ...statefulCurrentParameters }],
@@ -220,7 +220,7 @@ ${JSON.stringify(refresh, null, 2)}
220
220
  }
221
221
  // Refresh stateful parameters
222
222
  // This refreshes parameters that are stateful (they can be added, deleted separately from the resource)
223
- async refreshStatefulParameters(statefulParametersConfig) {
223
+ async refreshStatefulParameters(statefulParametersConfig, allParameters) {
224
224
  const result = {};
225
225
  const sortedEntries = Object.entries(statefulParametersConfig)
226
226
  .sort(([key1], [key2]) => this.parsedSettings.statefulParameterOrder.get(key1) - this.parsedSettings.statefulParameterOrder.get(key2));
@@ -229,7 +229,7 @@ ${JSON.stringify(refresh, null, 2)}
229
229
  if (!statefulParameter) {
230
230
  throw new Error(`Stateful parameter ${key} was not found`);
231
231
  }
232
- result[key] = await statefulParameter.refresh(desiredValue ?? null);
232
+ result[key] = await statefulParameter.refresh(desiredValue ?? null, allParameters);
233
233
  }
234
234
  return result;
235
235
  }
@@ -25,10 +25,11 @@ export declare abstract class StatefulParameter<T extends StringIndexedObject, V
25
25
  * Return the value of the stateful parameter or null if not found.
26
26
  *
27
27
  * @param desired The desired value of the user.
28
+ * @param config The desired config
28
29
  *
29
30
  * @return The value of the stateful parameter currently on the system or null if not found
30
31
  */
31
- abstract refresh(desired: V | null): Promise<V | null>;
32
+ abstract refresh(desired: V | null, config: Partial<T>): Promise<V | null>;
32
33
  /**
33
34
  * Create the stateful parameter on the system. This method is similar {@link Resource.create} except that its only
34
35
  * applicable to the stateful parameter. For resource `CREATE` operations, this method will be called after the
@@ -128,7 +129,7 @@ export declare abstract class ArrayStatefulParameter<T extends StringIndexedObje
128
129
  * @param desired The desired value to refresh
129
130
  * @return The current value on the system or null if not found.
130
131
  */
131
- abstract refresh(desired: V[] | null): Promise<V[] | null>;
132
+ abstract refresh(desired: V[] | null, config: Partial<T>): Promise<V[] | null>;
132
133
  /**
133
134
  * Helper method that gets called when individual elements of the array need to be added. See {@link StatefulParameter.add}
134
135
  * for more information.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "codify-plugin-lib",
3
- "version": "1.0.82",
3
+ "version": "1.0.84",
4
4
  "description": "Library plugin library",
5
5
  "main": "dist/index.js",
6
6
  "typings": "dist/index.d.ts",
@@ -112,6 +112,7 @@ export class ResourceController<T extends StringIndexedObject> {
112
112
  coreParameters,
113
113
  desiredParameters,
114
114
  stateParameters,
115
+ allParameters,
115
116
  allNonStatefulParameters,
116
117
  allStatefulParameters,
117
118
  } = parsedConfig;
@@ -138,7 +139,7 @@ export class ResourceController<T extends StringIndexedObject> {
138
139
 
139
140
  // Refresh stateful parameters. These parameters have state external to the resource. allowMultiple
140
141
  // does not work together with stateful parameters
141
- const statefulCurrentParameters = await this.refreshStatefulParameters(allStatefulParameters);
142
+ const statefulCurrentParameters = await this.refreshStatefulParameters(allStatefulParameters, allParameters);
142
143
 
143
144
  return Plan.calculate({
144
145
  desiredParameters,
@@ -298,7 +299,7 @@ ${JSON.stringify(refresh, null, 2)}
298
299
 
299
300
  // Refresh stateful parameters
300
301
  // This refreshes parameters that are stateful (they can be added, deleted separately from the resource)
301
- private async refreshStatefulParameters(statefulParametersConfig: Partial<T>): Promise<Partial<T>> {
302
+ private async refreshStatefulParameters(statefulParametersConfig: Partial<T>, allParameters: Partial<T>): Promise<Partial<T>> {
302
303
  const result: Partial<T> = {}
303
304
  const sortedEntries = Object.entries(statefulParametersConfig)
304
305
  .sort(
@@ -311,7 +312,7 @@ ${JSON.stringify(refresh, null, 2)}
311
312
  throw new Error(`Stateful parameter ${key} was not found`);
312
313
  }
313
314
 
314
- (result as Record<string, unknown>)[key] = await statefulParameter.refresh(desiredValue ?? null)
315
+ (result as Record<string, unknown>)[key] = await statefulParameter.refresh(desiredValue ?? null, allParameters)
315
316
  }
316
317
 
317
318
  return result;
@@ -31,10 +31,11 @@ export abstract class StatefulParameter<T extends StringIndexedObject, V extends
31
31
  * Return the value of the stateful parameter or null if not found.
32
32
  *
33
33
  * @param desired The desired value of the user.
34
+ * @param config The desired config
34
35
  *
35
36
  * @return The value of the stateful parameter currently on the system or null if not found
36
37
  */
37
- abstract refresh(desired: V | null): Promise<V | null>;
38
+ abstract refresh(desired: V | null, config: Partial<T>): Promise<V | null>;
38
39
 
39
40
  /**
40
41
  * Create the stateful parameter on the system. This method is similar {@link Resource.create} except that its only
@@ -179,7 +180,7 @@ export abstract class ArrayStatefulParameter<T extends StringIndexedObject, V> e
179
180
  * @param desired The desired value to refresh
180
181
  * @return The current value on the system or null if not found.
181
182
  */
182
- abstract refresh(desired: V[] | null): Promise<V[] | null>;
183
+ abstract refresh(desired: V[] | null, config: Partial<T>): Promise<V[] | null>;
183
184
 
184
185
  /**
185
186
  * Helper method that gets called when individual elements of the array need to be added. See {@link StatefulParameter.add}