codify-plugin-lib 1.0.66 → 1.0.67

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.
@@ -1,3 +1,5 @@
1
+ import { Plan } from './plan.js';
2
+ import { StringIndexedObject } from 'codify-schemas';
1
3
  export interface ParameterOptions {
2
4
  modifyOnChange?: boolean;
3
5
  isEqual?: (desired: any, current: any) => boolean;
@@ -9,3 +11,9 @@ export interface PlanOptions<T> {
9
11
  statefulMode: boolean;
10
12
  parameterOptions?: Record<keyof T, ParameterOptions>;
11
13
  }
14
+ export type WithRequired<T, K extends keyof T> = T & {
15
+ [P in K]-?: T[P];
16
+ };
17
+ export type CreatePlan<T extends StringIndexedObject> = WithRequired<Plan<T>, 'desiredConfig'>;
18
+ export type DestroyPlan<T extends StringIndexedObject> = WithRequired<Plan<T>, 'currentConfig'>;
19
+ export type ModifyPlan<T extends StringIndexedObject> = WithRequired<Plan<T>, 'currentConfig' | 'desiredConfig'>;
@@ -3,7 +3,7 @@ import { ParameterChange } from './change-set.js';
3
3
  import { Plan } from './plan.js';
4
4
  import { StatefulParameter } from './stateful-parameter.js';
5
5
  import { ResourceParameterOptions, ValidationResult } from './resource-types.js';
6
- import { ParameterOptions } from './plan-types.js';
6
+ import { CreatePlan, DestroyPlan, ModifyPlan, ParameterOptions } from './plan-types.js';
7
7
  import { TransformParameter } from './transform-parameter.js';
8
8
  import { ResourceOptions } from './resource-options.js';
9
9
  import Ajv from 'ajv';
@@ -36,8 +36,8 @@ export declare abstract class Resource<T extends StringIndexedObject> {
36
36
  private refreshStatefulParameters;
37
37
  private validatePlanInputs;
38
38
  validate(parameters: unknown): Promise<ValidationResult>;
39
- abstract refresh(keys: Map<keyof T, T[keyof T]>): Promise<Partial<T> | null>;
40
- abstract applyCreate(plan: Plan<T>): Promise<void>;
41
- applyModify(pc: ParameterChange<T>, plan: Plan<T>): Promise<void>;
42
- abstract applyDestroy(plan: Plan<T>): Promise<void>;
39
+ abstract refresh(values: Map<keyof T, T[keyof T]>): Promise<Partial<T> | null>;
40
+ abstract applyCreate(plan: CreatePlan<T>): Promise<void>;
41
+ applyModify(pc: ParameterChange<T>, plan: ModifyPlan<T>): Promise<void>;
42
+ abstract applyDestroy(plan: DestroyPlan<T>): Promise<void>;
43
43
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "codify-plugin-lib",
3
- "version": "1.0.66",
3
+ "version": "1.0.67",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "typings": "dist/index.d.ts",
@@ -1,3 +1,6 @@
1
+ import { Plan } from './plan.js';
2
+ import { StringIndexedObject } from 'codify-schemas';
3
+
1
4
  /**
2
5
  * Customize properties for specific parameters. This will alter the way the library process changes to the parameter.
3
6
  */
@@ -24,3 +27,8 @@ export interface PlanOptions<T> {
24
27
  statefulMode: boolean;
25
28
  parameterOptions?: Record<keyof T, ParameterOptions>;
26
29
  }
30
+
31
+ export type WithRequired<T, K extends keyof T> = T & { [P in K]-?: T[P] }
32
+ export type CreatePlan<T extends StringIndexedObject> = WithRequired<Plan<T>, 'desiredConfig'>
33
+ export type DestroyPlan<T extends StringIndexedObject> = WithRequired<Plan<T>, 'currentConfig'>
34
+ export type ModifyPlan<T extends StringIndexedObject> = WithRequired<Plan<T>, 'currentConfig' | 'desiredConfig'>
@@ -4,7 +4,7 @@ import { Plan } from './plan.js';
4
4
  import { StatefulParameter } from './stateful-parameter.js';
5
5
  import { ResourceParameterOptions, ValidationResult } from './resource-types.js';
6
6
  import { setsEqual, splitUserConfig } from '../utils/utils.js';
7
- import { ParameterOptions, PlanOptions } from './plan-types.js';
7
+ import { CreatePlan, DestroyPlan, ModifyPlan, ParameterOptions, PlanOptions } from './plan-types.js';
8
8
  import { TransformParameter } from './transform-parameter.js';
9
9
  import { ResourceOptions, ResourceOptionsParser } from './resource-options.js';
10
10
  import Ajv from 'ajv';
@@ -346,13 +346,13 @@ Additional: ${[...refreshKeys].filter(k => !desiredKeys.has(k))};`
346
346
  }
347
347
  };
348
348
 
349
- abstract refresh(keys: Map<keyof T, T[keyof T]>): Promise<Partial<T> | null>;
349
+ abstract refresh(values: Map<keyof T, T[keyof T]>): Promise<Partial<T> | null>;
350
350
 
351
- abstract applyCreate(plan: Plan<T>): Promise<void>;
351
+ abstract applyCreate(plan: CreatePlan<T>): Promise<void>;
352
352
 
353
- async applyModify(pc: ParameterChange<T>, plan: Plan<T>): Promise<void> {};
353
+ async applyModify(pc: ParameterChange<T>, plan: ModifyPlan<T>): Promise<void> {};
354
354
 
355
- abstract applyDestroy(plan: Plan<T>): Promise<void>;
355
+ abstract applyDestroy(plan: DestroyPlan<T>): Promise<void>;
356
356
  }
357
357
 
358
358
  class ConfigParser<T extends StringIndexedObject> {