codify-plugin-lib 1.0.68 → 1.0.69

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,11 +1,4 @@
1
- import { Plan } from './plan.js';
2
- import { StringIndexedObject } from 'codify-schemas';
3
1
  export declare class SudoError extends Error {
4
2
  command: string;
5
3
  constructor(command: string);
6
4
  }
7
- export declare class ApplyValidationError<T extends StringIndexedObject> extends Error {
8
- desiredPlan: Plan<T>;
9
- validatedPlan: Plan<T>;
10
- constructor(desiredPlan: Plan<T>, validatedPlan: Plan<T>);
11
- }
@@ -5,12 +5,3 @@ export class SudoError extends Error {
5
5
  this.command = command;
6
6
  }
7
7
  }
8
- export class ApplyValidationError extends Error {
9
- desiredPlan;
10
- validatedPlan;
11
- constructor(desiredPlan, validatedPlan) {
12
- super();
13
- this.desiredPlan = desiredPlan;
14
- this.validatedPlan = validatedPlan;
15
- }
16
- }
@@ -1,7 +1,5 @@
1
- import { ResourceOperation } from 'codify-schemas';
2
1
  import { Plan } from './plan.js';
3
2
  import { splitUserConfig } from '../utils/utils.js';
4
- import { ApplyValidationError } from './errors.js';
5
3
  export class Plugin {
6
4
  name;
7
5
  resources;
@@ -64,10 +62,6 @@ export class Plugin {
64
62
  throw new Error('Malformed plan with resource that cannot be found');
65
63
  }
66
64
  await resource.apply(plan);
67
- const validationPlan = await resource.plan(plan.desiredConfig, plan.currentConfig, true);
68
- if (validationPlan.changeSet.operation !== ResourceOperation.NOOP) {
69
- throw new ApplyValidationError(plan, validationPlan);
70
- }
71
65
  }
72
66
  resolvePlan(data) {
73
67
  const { planId, plan: planRequest } = data;
@@ -1,7 +1,7 @@
1
1
  import addFormats from 'ajv-formats';
2
2
  import { ApplyRequestDataSchema, ApplyResponseDataSchema, InitializeRequestDataSchema, InitializeResponseDataSchema, IpcMessageSchema, MessageStatus, PlanRequestDataSchema, PlanResponseDataSchema, ResourceSchema, ValidateRequestDataSchema, ValidateResponseDataSchema } from 'codify-schemas';
3
3
  import Ajv2020 from 'ajv/dist/2020.js';
4
- import { ApplyValidationError, SudoError } from '../entities/errors.js';
4
+ import { SudoError } from '../entities/errors.js';
5
5
  const SupportedRequests = {
6
6
  'initialize': {
7
7
  requestValidator: InitializeRequestDataSchema,
@@ -89,20 +89,6 @@ export class MessageHandler {
89
89
  data: `Plugin: '${this.plugin.name}'. Forbidden usage of sudo for command '${e.command}'. Please contact the plugin developer to fix this.`,
90
90
  });
91
91
  }
92
- if (e instanceof ApplyValidationError) {
93
- return process.send?.({
94
- cmd,
95
- status: MessageStatus.ERROR,
96
- data: `Plugin: '${this.plugin.name}'. Apply validation was not successful (additional changes are needed to match the desired plan).
97
-
98
- Validation plan:
99
- ${JSON.stringify(e.validatedPlan, null, 2)},
100
-
101
- User desired plan:
102
- ${JSON.stringify(e.desiredPlan, null, 2)}
103
- `
104
- });
105
- }
106
92
  const isDebug = process.env.DEBUG?.includes('*') ?? false;
107
93
  process.send?.({
108
94
  cmd,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "codify-plugin-lib",
3
- "version": "1.0.68",
3
+ "version": "1.0.69",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "typings": "dist/index.d.ts",
@@ -9,17 +9,3 @@ export class SudoError extends Error {
9
9
  this.command = command;
10
10
  }
11
11
  }
12
-
13
- export class ApplyValidationError<T extends StringIndexedObject> extends Error {
14
- desiredPlan: Plan<T>;
15
- validatedPlan: Plan<T>;
16
-
17
- constructor(
18
- desiredPlan: Plan<T>,
19
- validatedPlan: Plan<T>
20
- ) {
21
- super();
22
- this.desiredPlan = desiredPlan;
23
- this.validatedPlan = validatedPlan;
24
- }
25
- }
@@ -11,7 +11,6 @@ import {
11
11
  } from 'codify-schemas';
12
12
  import { Plan } from './plan.js';
13
13
  import { splitUserConfig } from '../utils/utils.js';
14
- import { ApplyValidationError } from './errors.js';
15
14
 
16
15
  export class Plugin {
17
16
  planStorage: Map<string, Plan<any>>;
@@ -92,17 +91,6 @@ export class Plugin {
92
91
  }
93
92
 
94
93
  await resource.apply(plan);
95
-
96
- // Perform a validation check after to ensure that the plan was properly applied.
97
- // Sometimes no errors are returned (exit code 0) but the apply was not successful
98
- const validationPlan = await resource.plan(
99
- plan.desiredConfig,
100
- plan.currentConfig,
101
- true,
102
- );
103
- if (validationPlan.changeSet.operation !== ResourceOperation.NOOP) {
104
- throw new ApplyValidationError(plan, validationPlan);
105
- }
106
94
  }
107
95
 
108
96
  private resolvePlan(data: ApplyRequestData): Plan<ResourceConfig> {
@@ -15,7 +15,7 @@ import {
15
15
  ValidateResponseDataSchema
16
16
  } from 'codify-schemas';
17
17
  import Ajv2020, { SchemaObject, ValidateFunction } from 'ajv/dist/2020.js';
18
- import { ApplyValidationError, SudoError } from '../entities/errors.js';
18
+ import { SudoError } from '../entities/errors.js';
19
19
 
20
20
  const SupportedRequests: Record<string, { requestValidator: SchemaObject; responseValidator: SchemaObject; handler: (plugin: Plugin, data: any) => Promise<unknown> }> = {
21
21
  'initialize': {
@@ -124,21 +124,6 @@ export class MessageHandler {
124
124
  })
125
125
  }
126
126
 
127
- if (e instanceof ApplyValidationError) {
128
- return process.send?.({
129
- cmd,
130
- status: MessageStatus.ERROR,
131
- data: `Plugin: '${this.plugin.name}'. Apply validation was not successful (additional changes are needed to match the desired plan).
132
-
133
- Validation plan:
134
- ${JSON.stringify(e.validatedPlan, null, 2)},
135
-
136
- User desired plan:
137
- ${JSON.stringify(e.desiredPlan, null, 2)}
138
- `
139
- })
140
- }
141
-
142
127
  const isDebug = process.env.DEBUG?.includes('*') ?? false;
143
128
 
144
129
  process.send?.({