@elyx-code/project-logic-tree 0.0.6623 → 0.0.6625

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.ts CHANGED
@@ -11120,7 +11120,7 @@ export declare class DefaultProjectLogicContext extends ExtensionContextBase<Ext
11120
11120
  toLatestChangeSet(author: string, timestamp: string, // ISO 8601 format
11121
11121
  self: UserManagedEntityState | null, autoclose?: boolean, autoCloseActionName?: string): ChangeSet;
11122
11122
  addChangeSet(changeSet: ChangeSet): ChangeSet;
11123
- discardChangeSet(changeSet: ChangeSet | null): ProjectState;
11123
+ discardChangeSet(changeSet: ChangeSet): ProjectState;
11124
11124
  subscribeDependents(dependencies: {
11125
11125
  entity: UserManagedEntityState;
11126
11126
  field: string;
@@ -28404,7 +28404,7 @@ export declare function getReferencedEntityStateOrErrors(data: ElementGeneration
28404
28404
  toLatestChangeSet(author: string, timestamp: string, // ISO 8601 format
28405
28405
  self: UserManagedEntityState | null, autoclose?: boolean, autoCloseActionName?: string): ChangeSet;
28406
28406
  addChangeSet(changeSet: ChangeSet): ChangeSet;
28407
- discardChangeSet(changeSet: ChangeSet | null): ProjectState;
28407
+ discardChangeSet(changeSet: ChangeSet): ProjectState;
28408
28408
  validateGeneratedUpdate(data: Partial<IProjectGenerationTarget>): {
28409
28409
  errors: EntityGenerationError[];
28410
28410
  modifiedData: Partial<IProjectGenerationTarget>;
@@ -31623,7 +31623,7 @@ export declare function getReferencedEntityStateOrErrors(data: ElementGeneration
31623
31623
  visitAsync(callback: (entity: Element_2 | ElementTransfer | EntityState | ElementShallowTransfer, knownEntitiesRecord: Record<EntityId, Element_2 | ElementTransfer | EntityState | ElementShallowTransfer>) => any, { yieldEvery }?: {
31624
31624
  yieldEvery?: number;
31625
31625
  }): Promise<Traverser>;
31626
- reverseVisitAsync(callback: (entity: Element_2 | ElementTransfer | EntityState | ElementShallowTransfer, knownEntitiesRecord: Record<EntityId, Element_2 | ElementTransfer | EntityState | ElementShallowTransfer>) => Promise<any>, { yieldEvery }?: {
31626
+ reverseVisitAsync(callback: (entity: Element_2 | ElementTransfer | EntityState | ElementShallowTransfer, knownEntitiesRecord: Record<EntityId, Element_2 | ElementTransfer | EntityState | ElementShallowTransfer>) => any, { yieldEvery }?: {
31627
31627
  yieldEvery?: number;
31628
31628
  }): Promise<Traverser>;
31629
31629
  }
package/dist/index.js CHANGED
@@ -93331,8 +93331,14 @@ class S extends qf {
93331
93331
  return this.autoclose && this.autoCloseActionName && this.autoCloseActionName === i && (this.self && n === ((l = this.self) == null ? void 0 : l.id) || !this.self) && await this.closeAsync(), this;
93332
93332
  }
93333
93333
  async closeAsync(i = {}) {
93334
+ if (!this.open || this.startedClose)
93335
+ return ne.warn(
93336
+ `Change-set (${this.id}) is already closed or in the process of closing.`
93337
+ ), this;
93334
93338
  const n = i.awaitBeforeClose ?? !0, l = i.awaitExtenalClosing ?? !0;
93335
- return this.startedClose || (this.startedClose = !0, n ? await this.beforeCloseAsync() : this.beforeCloseAsync()), !this.isValid && this.self && !this.added[this.self.id] && !this.updated[this.self.id] && this.removed[this.self.id], this.discardOrphans(), this.sanitize(), this.recursiveCaptureUpstreamVersions(), this.lockedVersions || (this.captureAllChangesInVersionInstances(), this.recursiveCaptureUpstreamVersions()), this.open = !1, this.isEmpty ? (ne.warn(`Empty change-set (${this.id}) discarded upon closing.`), this.project.discardChangeSet(this), this.project.closePendingChangeSets(), this) : (l ? await this.project.closeChangeSet(this) : this.project.closeChangeSet(this), this);
93339
+ return this.startedClose || (this.startedClose = !0, n ? await this.beforeCloseAsync() : this.beforeCloseAsync()), !this.isValid && this.self && !this.added[this.self.id] && !this.updated[this.self.id] && this.removed[this.self.id], this.discardOrphans(), this.sanitize(), this.recursiveCaptureUpstreamVersions(), this.lockedVersions || (this.captureAllChangesInVersionInstances(), this.recursiveCaptureUpstreamVersions()), this.open = !1, this.isEmpty ? (ne.warn(
93340
+ `[ChangeSet.closeAsync] Empty change-set (${this.id}) discarded upon closing.`
93341
+ ), this.dirty = !1, this.project.discardChangeSet(this), console.log("[ChangeSet.closeAsync] Closing pending change-sets..."), this.project.closePendingChangeSets(), this) : (l ? await this.project.closeChangeSet(this) : this.project.closeChangeSet(this), this);
93336
93342
  }
93337
93343
  attemptAutoclose(i, n) {
93338
93344
  var l;
@@ -93403,8 +93409,14 @@ class S extends qf {
93403
93409
  return aAi(this);
93404
93410
  }
93405
93411
  close() {
93412
+ if (!this.open || this.startedClose)
93413
+ return ne.warn(
93414
+ `Change-set (${this.id}) is already closed or in the process of closing.`
93415
+ ), this;
93406
93416
  if (this.startedClose || (this.startedClose = !0, this.beforeClose()), !this.isValid && this.self && !this.added[this.self.id] && !this.updated[this.self.id] && this.removed[this.self.id], this.discardOrphans(), this.sanitize(), this.captureAllChangesInVersionInstances(), this.lockedVersions || (this.recursiveCaptureUpstreamVersions(), this.captureAllChangesInVersionInstances()), this.open = !1, this.isEmpty)
93407
- return ne.warn(`Empty change-set (${this.id}) discarded upon closing.`), this.project.discardChangeSet(this), this.project.closePendingChangeSets(), this;
93417
+ return ne.warn(
93418
+ `[ChangeSet.close] Empty change-set (${this.id}) discarded upon closing.`
93419
+ ), this.project.discardChangeSet(this), console.log("[ChangeSet.close] Closing pending change-sets..."), this.project.closePendingChangeSets(), this;
93408
93420
  if (this.added[this.project.id] && this.updatedIds.length)
93409
93421
  throw new Error(
93410
93422
  "No 'updated' entities should be present in the change-set when the project entity is in the 'added' list. New projects can only have newly added entities"
@@ -192912,13 +192924,18 @@ const o6 = {
192912
192924
  return this.parentContext.events.emitAsyncSequentiallyAllSettled;
192913
192925
  }
192914
192926
  async closePendingChangeSets() {
192927
+ console.log("[ProjectState.closePendingChangeSets] called");
192915
192928
  const i = this.history.find(
192916
- (n) => n.dirty && !n.open
192929
+ (n) => n.dirty && !n.open && !n.startedClose
192917
192930
  );
192918
- i && await this.closeChangeSet(i);
192931
+ i && (console.log(
192932
+ `[ProjectState.closePendingChangeSets] closing pending change-set ${i.id} - ${i.autoCloseActionName}`
192933
+ ), await this.closeChangeSet(i));
192919
192934
  }
192920
192935
  async onCloseChangeSet(i) {
192921
- this.onCloseChangeSetCallback = i, await this.closePendingChangeSets();
192936
+ this.onCloseChangeSetCallback = i, console.log(
192937
+ "[ProjectState.onCloseChangeSet] onCloseChangeSetCallback has been set. Checking for pending change-sets."
192938
+ ), await this.closePendingChangeSets();
192922
192939
  }
192923
192940
  onAddChangeSet(i) {
192924
192941
  this.onAddChangeSetCallback = i;
@@ -192927,11 +192944,26 @@ const o6 = {
192927
192944
  this.onDiscardChangeSetCallback = i;
192928
192945
  }
192929
192946
  async closeChangeSet(i) {
192947
+ if (console.log(
192948
+ `[ProjectState.closeChangeSet] called for change-set ${i.id} - ${i.autoCloseActionName}`
192949
+ ), !i.open || i.startedClose || !i.dirty) {
192950
+ console.log(
192951
+ `[ProjectState.closeChangeSet] change-set ${i.id} - ${i.autoCloseActionName} is not open, started closing, or not dirty.`
192952
+ );
192953
+ return;
192954
+ }
192930
192955
  const n = this.history.findIndex((e) => e.id === i.id), l = this.history.slice(0, n), c = l[l.length - 1];
192931
- if (!(c != null && c.dirty) && this.onCloseChangeSetCallback) {
192932
- (await this.onCloseChangeSetCallback(i)).success && (i.dirty = !1, this.emit("change-set-closed", i), this.closePendingChangeSets());
192956
+ if (c != null && c.dirty) {
192957
+ console.log(
192958
+ `[ProjectState.closeChangeSet] lastBeforeSelf is dirty: ${c.id} - ${c.autoCloseActionName}, closing it first.`
192959
+ );
192933
192960
  return;
192934
192961
  }
192962
+ this.onCloseChangeSetCallback && (console.log(
192963
+ `[ProjectState.closeChangeSet] invoking onCloseChangeSetCallback for change-set ${i.id} - ${i.autoCloseActionName}`
192964
+ ), (await this.onCloseChangeSetCallback(i)).success && (i.dirty = !1, this.emit("change-set-closed", i), console.log(
192965
+ `[ProjectState.closeChangeSet] change-set ${i.id} - ${i.autoCloseActionName} closed successfully, checking for pending change-sets to close.`
192966
+ ), this.closePendingChangeSets()));
192935
192967
  }
192936
192968
  // Returns the last open change set or creates a new one with the information provided
192937
192969
  toLatestChangeSet(i, n, l, c = !1, e = "here-this") {
@@ -192988,8 +193020,13 @@ const o6 = {
192988
193020
  // So we remove them from the state
192989
193021
  discardChangeSet(i) {
192990
193022
  var l;
193023
+ console.log(
193024
+ `[ProjectState.discardChangeSet] called for change-set ${i.id} - ${i.autoCloseActionName}`
193025
+ );
192991
193026
  const n = this.history.findIndex((c) => c.id === (i == null ? void 0 : i.id));
192992
- return n !== -1 && (this.history.splice(n, 1), this.undoableStackValueIndex = this.undoableStackValueIndex - 1, (l = this.onDiscardChangeSetCallback) == null || l.call(this, i), i == null || i.teardown()), this;
193027
+ return n !== -1 && (this.history.splice(n, 1), console.log(
193028
+ `[ProjectState.discardChangeSet] Removed change-set ${i.id} - ${i.autoCloseActionName} from history.`
193029
+ ), this.undoableStackValueIndex = this.undoableStackValueIndex - 1, (l = this.onDiscardChangeSetCallback) == null || l.call(this, i), i == null || i.teardown()), this;
192993
193030
  }
192994
193031
  validateGeneratedUpdate(i) {
192995
193032
  return { errors: [], modifiedData: i };