@terraforge/terraform 0.0.24 → 0.0.26

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.
package/dist/index.d.mts CHANGED
@@ -204,8 +204,12 @@ type RefreshResourceProps<T = State> = {
204
204
  priorOutputState: T;
205
205
  };
206
206
  type RefreshResourceResult<T = State> = {
207
- kind: 'unchanged' | 'updated';
207
+ kind: 'unchanged';
208
208
  state: T;
209
+ } | {
210
+ kind: 'updated';
211
+ state: T;
212
+ inputState: T;
209
213
  } | {
210
214
  kind: 'deleted';
211
215
  };
@@ -310,12 +314,15 @@ declare class TerraformProvider implements Provider {
310
314
  }: RefreshResourceProps): Promise<{
311
315
  kind: "deleted";
312
316
  state?: undefined;
317
+ inputState?: undefined;
313
318
  } | {
314
319
  kind: "unchanged";
315
320
  state: State$1;
321
+ inputState?: undefined;
316
322
  } | {
317
323
  kind: "updated";
318
324
  state: State$1;
325
+ inputState: State;
319
326
  }>;
320
327
  }
321
328
  //#endregion
package/dist/index.mjs CHANGED
@@ -426,16 +426,6 @@ const formatOutputState = (schema, state, path = []) => {
426
426
 
427
427
  //#endregion
428
428
  //#region src/provider.ts
429
- const areStatesEqual = (left, right) => {
430
- const replacer = (_, value) => {
431
- if (value !== null && value instanceof Object && !Array.isArray(value)) return Object.keys(value).sort().reduce((sorted, key) => {
432
- sorted[key] = value[key];
433
- return sorted;
434
- }, {});
435
- return value;
436
- };
437
- return JSON.stringify(left, replacer) === JSON.stringify(right, replacer);
438
- };
439
429
  var TerraformProvider = class {
440
430
  configured;
441
431
  plugin;
@@ -529,28 +519,16 @@ var TerraformProvider = class {
529
519
  const schema = getResourceSchema(plugin.schema().resources, type);
530
520
  const refreshedState = await plugin.readResource(type, priorOutputState);
531
521
  if (!refreshedState) return { kind: "deleted" };
532
- const mergedState = {
533
- ...refreshedState,
534
- ...priorInputState
535
- };
536
- const { requiresReplace, plannedState } = await plugin.planResourceChange(type, refreshedState, mergedState, priorInputState);
537
- const normalizedPlannedState = normalizeStateForComparison(schema, plannedState, priorInputState);
522
+ const normalizedPriorInputState = normalizeStateForComparison(schema, priorInputState, priorInputState);
538
523
  const normalizedRefreshedState = normalizeStateForComparison(schema, refreshedState, priorInputState);
539
- if (requiresReplace.length === 0 && areStatesEqual(normalizedPlannedState, normalizedRefreshedState)) return {
524
+ if (JSON.stringify(normalizedPriorInputState) === JSON.stringify(normalizedRefreshedState)) return {
540
525
  kind: "unchanged",
541
526
  state: refreshedState
542
527
  };
543
- console.log("TYPE", type);
544
- console.log("PRIOR_INPUT_STATE", priorInputState);
545
- console.log("PRIOR_OUTPUT_STATE", priorOutputState);
546
- console.log("PLANNED_STATE", plannedState);
547
- console.log("REFRESH_STATE", refreshedState);
548
- console.log("NORMALIZED_PLANNED_STATE", normalizedPlannedState);
549
- console.log("NORMALIZED_REFRESH_STATE", normalizedRefreshedState);
550
- console.log("REQUIRES_REPLACE", requiresReplace);
551
528
  return {
552
529
  kind: "updated",
553
- state: refreshedState
530
+ state: refreshedState,
531
+ inputState: normalizedRefreshedState
554
532
  };
555
533
  }
556
534
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@terraforge/terraform",
3
- "version": "0.0.24",
3
+ "version": "0.0.26",
4
4
  "type": "module",
5
5
  "repository": {
6
6
  "type": "git",