codify-plugin-lib 1.0.59 → 1.0.60

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.
@@ -60,7 +60,7 @@ export class Resource {
60
60
  await this.applyTransformParameters(transformParameters, resourceParameters);
61
61
  const currentParameters = await this.refreshResourceParameters(resourceParameters);
62
62
  if (currentParameters == null) {
63
- return Plan.create(resourceParameters, null, resourceMetadata, planOptions);
63
+ return Plan.create(desiredParameters, null, resourceMetadata, planOptions);
64
64
  }
65
65
  const statefulCurrentParameters = await this.refreshStatefulParameters(statefulParameters, planOptions.statefulMode);
66
66
  return Plan.create({ ...resourceParameters, ...statefulParameters }, { ...currentParameters, ...statefulCurrentParameters }, resourceMetadata, planOptions);
package/dist/index.d.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  import { Plugin } from './entities/plugin.js';
2
2
  export * from './entities/resource.js';
3
3
  export * from './entities/resource-types.js';
4
+ export * from './entities/resource-options.js';
4
5
  export * from './entities/plugin.js';
5
6
  export * from './entities/change-set.js';
6
7
  export * from './entities/plan.js';
package/dist/index.js CHANGED
@@ -1,6 +1,7 @@
1
1
  import { MessageHandler } from './messages/handlers.js';
2
2
  export * from './entities/resource.js';
3
3
  export * from './entities/resource-types.js';
4
+ export * from './entities/resource-options.js';
4
5
  export * from './entities/plugin.js';
5
6
  export * from './entities/change-set.js';
6
7
  export * from './entities/plan.js';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "codify-plugin-lib",
3
- "version": "1.0.59",
3
+ "version": "1.0.60",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "typings": "dist/index.d.ts",
@@ -28,6 +28,48 @@ class TestParameter extends StatefulParameter<TestConfig, string> {
28
28
  }
29
29
 
30
30
  describe('Resource parameter tests', () => {
31
+ it ('Generates a resource plan that includes stateful parameters (create)', async () => {
32
+ const statefulParameter = spy(new class extends TestParameter {
33
+ async refresh(): Promise<string | null> {
34
+ return null;
35
+ }
36
+ })
37
+
38
+ const resource = new class extends TestResource {
39
+ constructor() {
40
+ super({
41
+ type: 'resource',
42
+ parameterOptions: {
43
+ propA: { statefulParameter }
44
+ },
45
+ });
46
+ }
47
+
48
+ async refresh(): Promise<any> {
49
+ return null;
50
+ }
51
+ }
52
+
53
+ const plan = await resource.plan({
54
+ type: 'resource',
55
+ propA: 'a',
56
+ propB: 10
57
+ })
58
+
59
+ expect(statefulParameter.refresh.notCalled).to.be.true;
60
+ expect(plan.currentConfig).toMatchObject({
61
+ type: 'resource',
62
+ propA: null,
63
+ propB: null,
64
+ })
65
+ expect(plan.desiredConfig).toMatchObject({
66
+ type: 'resource',
67
+ propA: 'a',
68
+ propB: 10
69
+ })
70
+ expect(plan.changeSet.operation).to.eq(ResourceOperation.CREATE);
71
+ })
72
+
31
73
  it('supports the creation of stateful parameters', async () => {
32
74
 
33
75
  const statefulParameter = new class extends TestParameter {
@@ -39,7 +81,6 @@ describe('Resource parameter tests', () => {
39
81
  const statefulParameterSpy = spy(statefulParameter);
40
82
 
41
83
  const resource = new class extends TestResource {
42
-
43
84
  constructor() {
44
85
  super({
45
86
  type: 'resource',
@@ -101,7 +101,7 @@ export abstract class Resource<T extends StringIndexedObject> {
101
101
 
102
102
  // Short circuit here. If the resource is non-existent, there's no point checking stateful parameters
103
103
  if (currentParameters == null) {
104
- return Plan.create(resourceParameters, null, resourceMetadata, planOptions);
104
+ return Plan.create(desiredParameters, null, resourceMetadata, planOptions);
105
105
  }
106
106
 
107
107
  // Refresh stateful parameters. These parameters have state external to the resource
package/src/index.ts CHANGED
@@ -3,6 +3,7 @@ import { MessageHandler } from './messages/handlers.js';
3
3
 
4
4
  export * from './entities/resource.js'
5
5
  export * from './entities/resource-types.js'
6
+ export * from './entities/resource-options.js'
6
7
  export * from './entities/plugin.js'
7
8
  export * from './entities/change-set.js'
8
9
  export * from './entities/plan.js'